3
votes

Basically, this is the log I get:

Started by user dontcare4free

$ hg clone --rev default ssh://[email protected]/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://[email protected]/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.

3

3 Answers

8
votes

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)

PATH=$PATH:/usr/local/bin
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.

4
votes

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.

0
votes

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?