Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial on Jenkins, installing and configuring

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?

like image 685
xmik Avatar asked Jul 19 '13 13:07

xmik


People also ask

How do I use mercurial with Jenkins?

Mercurial This plugin integrates the Mercurial version control system with Jenkins. With this plugin, you can designate a Mercurial repository as the "upstream" repository. Every build will then run something like hg pull -u to bring the tip of this upstream repository.

What versions of Mercurial are supported by this plugin?

This plugin is currently intended to support Mercurial 1.0 and later. Viewers are included for various hosted services. As of version 1.38 it's possible to trigger builds using push notifications instead of polling. In your repository's .hg/hgrc file add:

How does Jenkins affect SSH key setup?

TortoiseHG integrates directly with pageant/putty for it's ssh connections, and the toolkit in jenkins only calls the executable, so it looks like: Therefore, Jenkins has no direct influence on the SSH key setup for the user. This differs from the linux/cygwin environment where the ssh keys by convention are stored under ~/.ssh.

What is Mercurial_revision_number and when should I use it?

MERCURIAL_REVISION_NUMBER: the revision number for the changeset being built. since this number may be different in each clone of a repository, it is generally better to use MERCURIAL_REVISION. The plugin supports generic tool auto-installation methods for your Mercurial installation, though it does not publish a catalog of Mercurial versions.


1 Answers

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

like image 178
kraffenetti Avatar answered Nov 06 '22 12:11

kraffenetti