Take the 2-minute tour ×

Basically, this is the log I get:

Started by user dontcare4free

$ hg clone --rev default ssh://hg@bitbucket.org/dontcare4free/my-repository /var/lib/jenkins/workspace/Custom-MC-Server

* failed to import extension hgext.imerge: No module named imerge
remote: Host key verification failed.
abort: no suitable response from remote hg!
ERROR: Failed to clone ssh://hg@bitbucket.org/dontcare4free/my-repository
[Custom-MC-Server] $ hg log --rev . --template {node}
java.io.IOException: Cannot run program "hg" (in directory "/var/lib/jenkins/workspace/My-Repository"): java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:475)
at hudson.Proc$LocalProc.(Proc.java:244)
at hudson.Proc$LocalProc.(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:698)
at hudson.Launcher$ProcStarter.start(Launcher.java:329)
at hudson.Launcher$ProcStarter.join(Launcher.java:336)
at hudson.plugins.mercurial.MercurialSCM.joinWithPossibleTimeout(MercurialSCM.java:299)
at hudson.plugins.mercurial.HgExe.popen(HgExe.java:191)
at hudson.plugins.mercurial.HgExe.tip(HgExe.java:171)
at >hudson.plugins.mercurial.MercurialSCM.calcRevisionsFromBuild(MercurialSCM.java:255)
at hudson.scm.SCM._calcRevisionsFromBuild(SCM.java:304)
at hudson.model.AbstractProject.calcPollingBaseline(AbstractProject.java:1205)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1194)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:555)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:443)
at hudson.model.Run.run(Run.java:1376)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:175)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.(UNIXProcess.java:164)
at java.lang.ProcessImpl.start(ProcessImpl.java:81)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:468)
... 18 more
Jabber notifier plugin: Sending notification to: -snip-
Jabber notifier plugin: Notifying suspects
Jabber notifier plugin: Notifying culprits
Notifying upstream projects of job completion
Finished: FAILURE

As far as I can see this means that it can't find the hg executable. However, I get no such errors when I try executing hg as a build step (shell execute) with Mercurial integration disabled.

I've tried with and without changing installation directory and executable and I've even tried compiling (well, whatever of that there is) Mercurial manually from source, all to no avail.

EDIT: Silly me. I completely misread the log. The issue is not related to it not finding the hg executable at all, but it's actually because I forgot to set up my key properly.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Nullable is right, the issue isn't that the hg executable can't be found, but rather that the jenkins user doesn't have a public key.

The solution is as follows:

  1. Log in as the jenkins user
  2. Make sure the jenkins user has a public ssh key, which should be in .ssh/id_rsa.pub
  3. If not, generate one using ssh-keygen and don't specify a passphrase
  4. Issue cat .ssh/id_rsa.pub, copy the output.
  5. Log into bitbucket or github, add the public key you just copied into your account
  6. Try again!

Hope that helps, best of luck to anyone with this issue.

share|improve this answer

Inspecting http://localhost:8080/systemInfo Environment Variables > PATH displays "/usr/bin:/bin:/usr/sbin:/sbin". I can't determine why this is all that Jenkins sees. When logging in as the daemon configured user, I get a much larger set of paths.

I was able to help the Mercurial Plug-in find "hg" by creating a symlink to hg.

sudo ln -s /usr/local/bin/hg /usr/bin/hg 

I tried adding the following to /etc/profile (I restarted just in case)

export PATH

I verified that this modified my path by typing

echo $PATH

in Terminal. However, this path did not show up in Jenkins

I am able to work with the sym link solution but I'd really like to understand where Jenkins gets its Path.

share|improve this answer
Thanks - this also worked for resolving an issue with Webstorm not detecting hg –  My Head Hurts Jun 18 '13 at 9:23

My first thought would be that you should check the path to the hg executable in jenkins set up, if there is such an option, it may not point to the correct path.

If that doesn't help, make sure hg is on the PATH.

Looks like there might be some set up required according to this page http://www.pixelastic.com/blog/162:failed-to-import-extension-hgext-imerge-warning-on-dreamhost

Maybe that can fix your issue?

share|improve this answer
Yes, it is in the path. Yes, the path in Jenkins is correctly set up. –  Teo Klestrup Röijezon Jul 22 '11 at 18:17
I'm experiencing the same issue. I solved it by creating a sym link from /usr/bin/hg to /usr/local/bin/hg. The latter being the install location for hg (mercurial). Once I did this, the mercurial plugin could find the program. However, this is not the most elegant solution. I'll post as an answer but I'd love some advice on what the correct solution might be. I tried modifying $PATH in /etc/profile but jenkins still reports a different path –  levous Nov 3 '11 at 14:51

Your Answer


