Saturday 21 January 2012

Setting up Jenkins to work with Mercurial on Windows

After spending one day trying to get a build working on a machine other than my development laptop, I decided it was time to setup the project on a continuous integration server.

As I had some trouble getting Jenkins to work with Mercurial, I thought I'd document the steps here for reference.

Environment (pre Jenkins)

  • Windows Server 2008
  • Mercurial Source Control (hosted on BitBucket)


Quickstart
  1. Install Jenkins (1.448)
  2. Install TortoiseHg (2.2.2)

Setup Plugins in Jenkins
> Manage Jenkins > Manage Plugins > Available

Tick the boxes for these plugins:
  • Mercurial Plugin
  • MSBuild Plugin
> Download now and install after restart
> Restart Jenkins when installation is complete and no jobs are running

Mercurial will appear under Source Code Management when you configure a job.
MSBuild will be available under the Build header when you configure a job.

Getting Mercurial working with Jenkins
HTTP
I got this working by changing the account Jenkins runs under (> Start > Run > services.msc > Jenkins > Log On >  This account:), from the local system account, to my account (Note: my account is an admin account, so I'll have to create a Jenkins only account, with less permissions. It's not secure to have a service run under admin!).

Mercurial could then access my username and password, as setup in C:\Users\username\mercurial.ini

SSH
I could not get the Mercurial plugin to work with SSH adequately, but I tried, you can read on, but it may not prove useful nor interesting.

For the Repository URL field, I put in my BitBucket SSH url - ssh://hg@bitbucket.org/username/repository


When I tried to build the project, Jenkins would just hang indefinitely on:


hg clone --rev default --noupdate ssh://hg@bitbucket.org/username/repository "C:\Program Files\Jenkins\jobs\Test\workspace"

So I ran the command myself on the command prompt.

Up pops PuTTY Security Alert, asking if you trust the host, and want to cache the rsa key fingerprint - it appears that Jenkins cannot get past this screen.

As Jenkins is running under the local system account, I decided to see if changing it to run under my account (> Start > Run > services.msc > Jenkins > Log On >  This account:) would make a difference. It did, I assume this is because PuTTY has cached the security key under my account settings.

But I then ran into this error:

remote: No supported authentication methods left to try!
abort: no suitable response from remote hg!

So I used Pageant to add the BitBucket private (ppk) key file (created by myself).

But then I ran into this error, again:

remote: No supported authentication methods left to try!
abort: no suitable response from remote hg!

So I tried the command prompt myself, it worked. Then I tried Jenkins, and it worked. However, Jenkins' Mercurial plugin only works with SSH IF I setup Pageant and run a hg command manually first. Pretty shite IMO.

Wednesday 18 January 2012

Visual Studio Counterintuivity, Edit and Continue

Changes are not allowed while code is running or if the option 'Break all processes when one process breaks' is disabled. The option can be enabled in Tools, Options, Debugging.



I had to disable Edit and Continue in order to use it.