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

Jobs don't find "hg" executable after reloading "Configuration as Code"

      We just switched to Jenkins Configuration as Code to have our configuration changes under version control. However after (re-)loading the the configuration, jobs which have configured Mercurial as their SCM don't find the Mercurial executable anymore, emitting the following error:

      java.io.IOException: Cannot determine tool home for MercurialInstallation[Mercurial]
      	at hudson.plugins.mercurial.HgExe.findHgExe(HgExe.java:206)
      	at hudson.plugins.mercurial.HgExe.<init>(HgExe.java:112)
      	at hudson.plugins.mercurial.MercurialSCM.clone(MercurialSCM.java:767)
      	at hudson.plugins.mercurial.MercurialSCM.checkout(MercurialSCM.java:586)
      	at hudson.scm.SCM.checkout(SCM.java:505)
      	at hudson.model.AbstractProject.checkout(AbstractProject.java:1213)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
      	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
      	at hudson.model.Run.execute(Run.java:1888)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:99)
      	at hudson.model.Executor.run(Executor.java:432)

      The issue is resolved after simply opening "Global Tool Configuration" and hitting the "Save" button there (without doing any modification). However, reloading CasC brings it back again.

      The configuration has been exported from a running Jenkins and is re-imported unmodified. It looks like this:

      tool: 
        ...
        mercurialInstallation: 
          installations: 
          - config: |-
              [defaults]
              clone = --uncompressed
            debug: false
            executable: "hg"
            name: "Mercurial"
            useCaches: true
            useSharing: false
      

      I could reproduce this on Jenkins 2.263.1 with JCasC 1.54 and Mercurial 2.12 as well as Jenkins 2.319.1 with JCasC 1.55 and Mercurial 2.16 running jobs on Windows and Linux agents and on the controller (Linux).

          [JENKINS-67495] Jobs don't find "hg" executable after reloading "Configuration as Code"

          Any news on this? It's quite annoying having to open and save the tools configuration page every time we reload JCasC.

          Dirk Heinrichs added a comment - Any news on this? It's quite annoying having to open and save the tools configuration page every time we reload JCasC.

          Found the reason, and a workaround. The "home" attribute is not exported and is thus set to "null" when it's re-imported. Changing the above to

          tool: 
            ...
            mercurialInstallation: 
              installations: 
              - config: |-
                  [defaults]
                  clone = --uncompressed
                debug: false
                executable: "hg"
                home: ""
                name: "Mercurial"
                useCaches: true
                useSharing: false
          

          works around this.

          Dirk Heinrichs added a comment - Found the reason, and a workaround. The "home" attribute is not exported and is thus set to "null" when it's re-imported. Changing the above to tool: ... mercurialInstallation: installations: - config: |- [defaults] clone = --uncompressed debug: false executable: "hg" home: "" name: "Mercurial" useCaches: true useSharing: false works around this.

          Jesse Glick added a comment -

          Not sure whether this is a problem in mercurial, configuration-as-code, or Jenkins core.

          Jesse Glick added a comment - Not sure whether this is a problem in mercurial , configuration-as-code , or Jenkins core.

            Unassigned Unassigned
            dhs Dirk Heinrichs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: