Mercurial on Jenkins, installing and configuring

xmik picture xmik · Jul 19, 2013 · Viewed 9.7k times · Source

I have a Mercurial repository (on Bitbucket) with some code (Java) and I want to do CI builds on a cloud-based Jenkins server (at Jelastic, running on CentOS). My problem is that I haven't been able to do a proper installation of Mercurial on the Jenkins server.

The Jenkins build fails with the following message:

ERROR: Failed to clone https://bitbucket_jenkins_user:[email protected]/repo_owner/my_repository because hg could not be found; check that you've properly configured your Mercurial installation

Setup information

  1. It's a private Mercurial repository, hosted at Bitbucket
  2. In Bitbucket I have set up a Service to trigger the Jenkins build, after a Push has happened
  3. I have defined a specific bitbucket jenkins user in my Mercurial repository, it has only read rights and it logs in using simple https authentication
  4. Jenkins runs on a Tomcat 7, hosted in a Jelastic cloud environment, on CentOS 6
  5. The Mercurial plugin was installed through the Jenkins interface, by Manage plugins
  6. The build is configured as being triggered remotely (by the service defined in Bitbucket)
  7. Build results are the same when started manually and when triggered from a push to the repository

When I first did this I was under the impression that installing the Mercurial plugin in Jenkins would be enough, that it would also install the needed Mercurial binaries to be able to connect to the repository and get the code. I have realized that I was wrong and that on the Manage Jenkins / Configure System page I need to specify my Mercurial installation.

Questions

  • Is it possible to create a Mercurial installation without ssh access and doing a "yum install mercurial"?
    • In the Jenkins interface, what can I specify when choosing the "Install Automatically" option?
    • When defining an installer, I have experimented with the "Extract zip/tar.gz" option, but what can I write as the "Download URL for binary archive"?
    • Jenkins also offers an installer option of "Run command". What kind of commands could that be, maybe a "yum install ..." or "rpm ..."?

Since my server is cloud based, getting ssh access is a paid add-on which I would prefer to avoid. But if that is my only option I will of course do it, thereby getting access to running commands on the server. However, running "yum install mercurial" on Centos seems to only give the 1.4 version of Mercurial. Current version when I write this is 2.6.3, would I need to download the sources and compile it myself or is it possible to get that as a binary for Centos somewhere?

Answer

kraffenetti picture kraffenetti · Sep 10, 2013

The Mercurial Plugin page has a section on how to use the Auto Installation options to install Mercurial using ArchLinux packages.

"The plugin supports generic tool auto-installation methods for your Mercurial installation, though it does not publish a catalog of Mercurial versions. For users of Linux machines (with Python preinstalled), you can use ArchLinux packages. For example, in /configure under Mercurial installations, add a Mercurial installation with whatever Name you like, Executable = INSTALLATION/bin/hg, Install automatically, Run Command, Label = linux (if desired to limit this to slaves configured with the same label), Command = [ -d usr ] || wget -q -O - http://www.archlinux.org/packages/extra/i686/mercurial/download/ | xzcat | tar xvf - (or …/x86_64/… for 64-bit slaves), Tool Home = usr, and configure a job with this installation tied to a Linux slave."

see https://wiki.jenkins-ci.org/display/JENKINS/Mercurial+Plugin