Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-67511

init.groovy not run on Windows agents

    XMLWordPrintable

Details

    Description

      Jenkins is running as a service on my Windows Agent, my Master is running on Ubuntu. The environment variable JENKINS_HOME is not set, but based on various searches I believe the jenkins home directory to be:
      C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\secrets

      To test, I added the following files and folders

      init.groovy

      init.groovy.d

        - init.groovy

      the file should basically log a text to the Master's system log, like so:

         def logger = LogManager.getLogManager().getLogger("")

         logger.info("Jenkins Startup Script: It ran ! : ")

         logger.info("Jenkins Startup Script: It ran ! : ${jenkinsHome}/init.groovy.d ")

       

      Since I wasn't sure of the actual JENKINS_HOME, I added the init.groovy both all these locations:

      C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\secrets\init.groovy

      C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\secrets\init.groovy.d\init.groovy

      C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\init.groovy

      C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\init.groovy.d\init.groovy

      C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\war\WEB-INF\init.groovy

      C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\war\WEB-INF\init.groovy.d\init.groovy

      I restarted the Jenkins service, but as far as I can tell none of these were ever run, and nothing was ever sent to the log.

      I'm new to Jenkins, so maybe I did it wrong, but it appears init.groovy is not executed on windows agents?

       

       

       

       

      Attachments

        Activity

          mwinter69 Markus Winter added a comment -

          An init.groovy script is not run on agents, it is only run on the master during startup

          mwinter69 Markus Winter added a comment - An init.groovy script is not run on agents, it is only run on the master during startup
          themightypope Anders Heie added a comment -

          Oh... That is not entirely clear from the online documentation... 

          Too bad, it would have been very useful.

          Thanks

          themightypope Anders Heie added a comment - Oh... That is not entirely clear from the online documentation...  Too bad, it would have been very useful. Thanks

          People

            escoem Emilio Escobar
            themightypope Anders Heie
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: