Setup Jenkins on TomCat/Windows with Mercurial Repository in BitBucket over SSH

This is just the list of steps that I’ve made to get a Windows build machine execute a Jenkins Job (running inside TomCat) clone a Mercurial repository hosted on BitBucket with SSH authentication.

  • Install TomCat (I’ve used the 7)
  • Install Jenkins on TomCat
  • Create a Windows User for executing the TomCat (Lets reference it as CI_USER, but you can name it as you like)
  • Set the TomCat process to execute with the CI_USER
  • Log in on the machine with the CI_USER
    • Download putty zip so that you can create a SSH key.
      • Generate a key using “PUTTYGEN.EXE”
      • Copy the Public-key and add it as a Deployment keys on your Repository settings on BitBucket.
      • Save the private key without a passphrase.
    • Install TortoiseHG on the Jenkins Machine.
    • Create a user Mercurial settings file on C:\Documents and Settings\CI_USER\Mercurial.ini (Look here for references)
    • Add this code to the file

      [ui]
      ssh=”C:\PATH_TO_TORTOISE_HG_INSTALL_ROOT\TortoisePlink.exe” -batch -i “C:\PATH_TO_PRIVATE_KEY_FILE_CREATED_WITH_PUTTYGEN.ppk”

    • I’m not really sure if this step is really mandatory, but do it just in case:
      • Manually clone your repo using TortoiseHG. Make sure you use the ssh url from bitbucket as source and some temporary folder as destination.
      • Accept Bitbucket certificate and add it to the cache (Click yes if any window appears regarding that)
    • Install the Mercurial plugin on Jenkins.
    • Go to jenkins and configure your job to point to the ssh url
    • Happy CI
    Advertisements

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: