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

Jenkins fails to run "hg" command even though the path to it is specified correctly

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Fixed
    • mercurial-plugin
    • None

    Description

      Jenkins fails to run "hg" command. Mercurial is installed as /usr/local/bin/hg, Jenkins fails to find it both when given full path and when given just "hg". Outside of Jenkins it works fine.

      Here's a stack trace:

      Started by user vg
      $ hg clone --rev default https://bitbucket.org/vgrichina/aqgridview /Users/vg/.jenkins/workspace/AQGridView-hg
      ERROR: Failed to clone https://bitbucket.org/vgrichina/aqgridview
      java.io.IOException: Cannot run program "hg": error=2, No such file or directory
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
      at hudson.Proc$LocalProc.<init>(Proc.java:244)
      at hudson.Proc$LocalProc.<init>(Proc.java:216)
      at hudson.Launcher$LocalLauncher.launch(Launcher.java:707)
      at hudson.Launcher$ProcStarter.start(Launcher.java:338)
      at hudson.Launcher$ProcStarter.join(Launcher.java:345)
      at hudson.plugins.mercurial.MercurialSCM.clone(MercurialSCM.java:577)
      at hudson.plugins.mercurial.MercurialSCM.checkout(MercurialSCM.java:422)
      at hudson.model.AbstractProject.checkout(AbstractProject.java:1195)
      at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:568)
      at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:457)
      at hudson.model.Run.run(Run.java:1404)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:230)
      Caused by: java.io.IOException: error=2, No such file or directory
      at java.lang.UNIXProcess.forkAndExec(Native Method)
      at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)
      at java.lang.ProcessImpl.start(ProcessImpl.java:91)
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
      ... 14 more

      Attachments

        Issue Links

          Activity

            vgrichina Vladimir Grichina created issue -

            My fault, I misinterpreted the error, it was because of no access to repository.

            I think the issue still remains though - error messages should be more clear.

            vgrichina Vladimir Grichina added a comment - My fault, I misinterpreted the error, it was because of no access to repository. I think the issue still remains though - error messages should be more clear.
            vgrichina Vladimir Grichina made changes -
            Field Original Value New Value
            Priority Blocker [ 1 ] Minor [ 4 ]
            davidmc24 davidmc24 added a comment -

            Looks like the problem is that in cases where clone fails, it tries to generate the changelog anyway. When it tries to run hg in the repo root, the directory doesn't exist (because it wasn't created by clone) resulting in a big ugly error. I'll take a stab at clarifying the error output by not attempting the changelog when clone fails.

            davidmc24 davidmc24 added a comment - Looks like the problem is that in cases where clone fails, it tries to generate the changelog anyway. When it tries to run hg in the repo root, the directory doesn't exist (because it wasn't created by clone) resulting in a big ugly error. I'll take a stab at clarifying the error output by not attempting the changelog when clone fails.
            davidmc24 davidmc24 made changes -
            Assignee Kohsuke Kawaguchi [ kohsuke ] davidmc24 [ davidmc24 ]
            davidmc24 davidmc24 added a comment -

            Correction; the stacktrace here was a failure on the initial clone failing. There are other similar issues where an initial clone failing can lead to subsequent misleading error messages.

            davidmc24 davidmc24 added a comment - Correction; the stacktrace here was a failure on the initial clone failing. There are other similar issues where an initial clone failing can lead to subsequent misleading error messages.

            Code changed in jenkins
            User: David M. Carr
            Path:
            src/main/java/hudson/plugins/mercurial/MercurialSCM.java
            http://jenkins-ci.org/commit/mercurial-plugin/f06a86a8d1eea9e9d95740e6fedfe54327e76092
            Log:
            JENKINS-11877 Don't attempt changelog calculation if clone/update failed

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: David M. Carr Path: src/main/java/hudson/plugins/mercurial/MercurialSCM.java http://jenkins-ci.org/commit/mercurial-plugin/f06a86a8d1eea9e9d95740e6fedfe54327e76092 Log: JENKINS-11877 Don't attempt changelog calculation if clone/update failed
            dogfood dogfood added a comment -

            Integrated in plugins_mercurial #81
            JENKINS-11877 Don't attempt changelog calculation if clone/update failed

            david :
            Files :

            • src/main/java/hudson/plugins/mercurial/MercurialSCM.java
            dogfood dogfood added a comment - Integrated in plugins_mercurial #81 JENKINS-11877 Don't attempt changelog calculation if clone/update failed david : Files : src/main/java/hudson/plugins/mercurial/MercurialSCM.java
            davidmc24 davidmc24 added a comment -

            The following pull request for core should address another possible form of this problem.

            https://github.com/jenkinsci/jenkins/pull/323

            davidmc24 davidmc24 added a comment - The following pull request for core should address another possible form of this problem. https://github.com/jenkinsci/jenkins/pull/323

            Code changed in jenkins
            User: David M. Carr
            Path:
            src/main/java/hudson/plugins/mercurial/MercurialSCM.java
            http://jenkins-ci.org/commit/mercurial-plugin/2fff702a0494aa7ecf220dcdac10454cb8ae3b08
            Log:
            JENKINS-11877 Improve error message when hg cannot be found

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: David M. Carr Path: src/main/java/hudson/plugins/mercurial/MercurialSCM.java http://jenkins-ci.org/commit/mercurial-plugin/2fff702a0494aa7ecf220dcdac10454cb8ae3b08 Log: JENKINS-11877 Improve error message when hg cannot be found

            Code changed in jenkins
            User: David M. Carr
            Path:
            src/main/java/hudson/plugins/mercurial/MercurialSCM.java
            http://jenkins-ci.org/commit/mercurial-plugin/e75bd4df0bc492542b7235e7584243e048b41632
            Log:
            [FIXED JENKINS-11877] Use AbortException rather than returning false to indicate checkout failure

            Compare: https://github.com/jenkinsci/mercurial-plugin/compare/f06a86a...e75bd4d

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: David M. Carr Path: src/main/java/hudson/plugins/mercurial/MercurialSCM.java http://jenkins-ci.org/commit/mercurial-plugin/e75bd4df0bc492542b7235e7584243e048b41632 Log: [FIXED JENKINS-11877] Use AbortException rather than returning false to indicate checkout failure Compare: https://github.com/jenkinsci/mercurial-plugin/compare/f06a86a...e75bd4d
            scm_issue_link SCM/JIRA link daemon made changes -
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Resolved [ 5 ]
            dogfood dogfood added a comment -

            Integrated in plugins_mercurial #82
            JENKINS-11877 Improve error message when hg cannot be found
            [FIXED JENKINS-11877] Use AbortException rather than returning false to indicate checkout failure

            david :
            Files :

            • src/main/java/hudson/plugins/mercurial/MercurialSCM.java

            david :
            Files :

            • src/main/java/hudson/plugins/mercurial/MercurialSCM.java
            dogfood dogfood added a comment - Integrated in plugins_mercurial #82 JENKINS-11877 Improve error message when hg cannot be found [FIXED JENKINS-11877] Use AbortException rather than returning false to indicate checkout failure david : Files : src/main/java/hudson/plugins/mercurial/MercurialSCM.java david : Files : src/main/java/hudson/plugins/mercurial/MercurialSCM.java
            davidmc24 davidmc24 made changes -
            Fix Version/s current [ 10162 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 142120 ] JNJira + In-Review [ 189983 ]
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-29045 [ JENKINS-29045 ]

            People

              davidmc24 davidmc24
              vgrichina Vladimir Grichina
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: