<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ted Naleid &#187; hudson</title>
	<atom:link href="http://naleid.com/blog/category/hudson/feed/" rel="self" type="application/rss+xml" />
	<link>http://naleid.com/blog</link>
	<description>Groovy, Grails and OS X tips and tricks</description>
	<lastBuildDate>Wed, 16 Jun 2010 17:38:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hooking up Hudson to your bitbucket mercurial account</title>
		<link>http://naleid.com/blog/2009/12/21/hooking-up-hudson-to-your-bitbucket-mercurial-account/</link>
		<comments>http://naleid.com/blog/2009/12/21/hooking-up-hudson-to-your-bitbucket-mercurial-account/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 06:29:12 +0000</pubDate>
		<dc:creator>tednaleid</dc:creator>
				<category><![CDATA[hudson]]></category>

		<guid isPermaLink="false">http://naleid.com/blog/?p=113</guid>
		<description><![CDATA[This past weekend, I saw @wakaleo running into some issues getting bitbucket hooked up to hudson.
I responded with a long reply that I thought would be worth cleaning up and posting here.

Mercurial, Bitbucket and Hudson
I&#8217;ve been using Mercurial as my personal revision control system for a while now.
I&#8217;ve more recently been using it at work [...]]]></description>
			<content:encoded><![CDATA[<p>This past weekend, I saw <a href="http://twitter.com/wakaleo" onclick="pageTracker._trackPageview('/outgoing/twitter.com/wakaleo?referer=');">@wakaleo</a> running into <a href="http://twitter.com/wakaleo/status/6789413053" onclick="pageTracker._trackPageview('/outgoing/twitter.com/wakaleo/status/6789413053?referer=');">some issues getting bitbucket hooked up to hudson</a>.</p>
<p>I <a href="http://twitter.com/tednaleid/status/6800126659" onclick="pageTracker._trackPageview('/outgoing/twitter.com/tednaleid/status/6800126659?referer=');">responded</a> with <a href="http://a.longreply.com/248600" onclick="pageTracker._trackPageview('/outgoing/a.longreply.com/248600?referer=');">a long reply</a> that I thought would be worth cleaning up and posting here.<br />
<span id="more-113"></span></p>
<h3>Mercurial, Bitbucket and Hudson</h3>
<p>I&#8217;ve been using <a href="http://mercurial.selenic.com/" onclick="pageTracker._trackPageview('/outgoing/mercurial.selenic.com/?referer=');">Mercurial</a> as my personal revision control system <a href="http://naleid.com/blog/2008/11/25/my-mercurial-setup-plus-some-useful-shims-and-jigs/">for a</a> <a href="http://naleid.com/blog/2009/11/08/mercurial-dvcs-devjam-presentation/">while now</a>.</p>
<p>I&#8217;ve more recently been using it at work with a repository hosted at <a href="http://bitbucket.org/" onclick="pageTracker._trackPageview('/outgoing/bitbucket.org/?referer=');">BitBucket</a>, a great service that offers free accounts (including one private repo) and very <a href="http://bitbucket.org/plans/" onclick="pageTracker._trackPageview('/outgoing/bitbucket.org/plans/?referer=');">reasonable upgraded accounts</a>.   (I don&#8217;t have any relationship with bitbucket other than just as a happy and satisfied user.)</p>
<p>Being a good agile shop, we use <a href="http://hudson-ci.org/" onclick="pageTracker._trackPageview('/outgoing/hudson-ci.org/?referer=');">hudson</a> as our <a href="http://martinfowler.com/articles/continuousIntegration.html" onclick="pageTracker._trackPageview('/outgoing/martinfowler.com/articles/continuousIntegration.html?referer=');">continuous integration</a> server (much better than Cruise Control IMO).  It polls the source control repository on a periodic basis, if it sees any code changes, it checks them out and runs all of the tests.</p>
<h3> Quick Mercurial/Hudson Setup</h3>
<h5>Install Mercurial</h5>
<p>There are lots of ways to <a href="http://mercurial.selenic.com/wiki/Download" onclick="pageTracker._trackPageview('/outgoing/mercurial.selenic.com/wiki/Download?referer=');">install mercurial</a>.  On the Ubuntu box, the quickest way to get a recent version for me was to just use python&#8217;s easy_install:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> easy_install mercurial</pre></div></div>

<h5>Install Hudson</h5>
<p>There are better guides out there for getting Hudson going depending on the platform you&#8217;re using, but here&#8217;s the quick instructions for how I got it going on an Ubuntu 9.10 image running on Amazon EC2.</p>
<p>Using Ubuntu&#8217;s apt-get package management, installing hudson is easy.  You need to add the repository that has the hudson source so that apt-get knows where to get it.  Add this to your <code>/etc/apt/sources.list</code> file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">deb http:<span style="color: #000000; font-weight: bold;">//</span>hudson-ci.org<span style="color: #000000; font-weight: bold;">/</span>debian binary<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Then update apt-get and install hudson:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> hudson</pre></div></div>

<p>That creates a hudson install with a new &#8220;hudson&#8221; user on your system.  </p>
<h3>Setting up Hudson to SSH</h3>
<p>We want this user to be able to connect to BitBucket over SSH and check out the repository.  To do this, we&#8217;ll need an ssh public and private key that hudson can use.  Sudo to the hudson user and generate one:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">su</span> - hudson
&nbsp;
<span style="color: #666666; font-style: italic;"># cd to the home dir, default in /var/lib/hudson</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ~
&nbsp;
<span style="color: #666666; font-style: italic;"># create the ssh key in the ~/.ssh directory</span>
<span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa
&nbsp;
<span style="color: #666666; font-style: italic;"># that creates the public/private key in the /var/lib/hudson.ssh directory</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub</pre></div></div>

<p>Copy that key to your clipboard (make sure to get all of it, it&#8217;s all one big line that probably has wrapped in your terminal window a couple of times).  We&#8217;ll be using this as our identification on bitbucket.</p>
<h5>Give the Public Key to BitBucket</h5>
<p>If you&#8217;ve already got a BitBucket account that you want to give Hudson access to go to it now.  Otherwise, create a new account for Hudson to use.  Go to the <a href="http://bitbucket.org/account/" onclick="pageTracker._trackPageview('/outgoing/bitbucket.org/account/?referer=');">&#8220;account&#8221; page</a> and paste the public key in the &#8220;SSH Keys&#8221; field and hit the &#8220;add key&#8221; button.</p>
<p>If this is the account that owns the repository (or already has access to it), you&#8217;re done on BitBucket.  Otherwise, if it&#8217;s a private repository owned by another user, you&#8217;ll need to add the hudson bitbucket user as a &#8220;read-only&#8221; user to the repository on the repository&#8217;s &#8220;admin&#8221; screen (or ask the repo owner to do that).</p>
<p>Then, go to the repository and get the ssh clone string for the repo you want to clone.  By default, bitbucket shows you the HTTPS clone string, which will NOT work with this authentication method.  To see it, click on the &#8220;SSH&#8221; link and it should show you something like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hg clone <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span>hg<span style="color: #000000; font-weight: bold;">@</span>bitbucket.org<span style="color: #000000; font-weight: bold;">/</span>tednaleid<span style="color: #000000; font-weight: bold;">/</span>grails-test-data<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>If the protocol in the url is &#8220;ssh&#8221;, you&#8217;ve got the right one.</p>
<h5>Finish Hudson Setup</h5>
<p>Back on the hudson box, you&#8217;ll want to manually clone the repo as the hudson user so that bitbucket is in the <code>~/.ssh/known_hosts</code> file.  Just execute the ssh clone command we found above:</p>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hg clone <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span>hg<span style="color: #000000; font-weight: bold;">@</span>bitbucket.org<span style="color: #000000; font-weight: bold;">/</span>tednaleid<span style="color: #000000; font-weight: bold;">/</span>grails-test-data<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>ssh will prompt you to add the host to the list of known hosts and then will clone the repo.  If that works, authentication is set up right and we&#8217;re almost done.</p>
<h5>Install the Mercurial plugin in Hudson</h5>
<p>All that&#8217;s left to do now is install the Mercurial plugin in hudson.  In a browser, go to http://INSERT_YOUR_IP_HERE:8080.  Hudson should come up.  </p>
<p>Click on &#8220;Manage Hudson&#8221; and go to &#8220;Manage Plugins&#8221;.  Go to the &#8220;Available&#8221; tab, check &#8220;Hudson Mercurial plugin&#8221; and hit the &#8220;Install&#8221; button.  Hudson will prompt you to restart, and then it&#8217;s installed.</p>
<p>After that, just create a new job and you&#8217;ll have a new &#8220;mercurial&#8221; option in the &#8220;source control management&#8221; section.  Select that and put the ssh URL in the &#8220;Repository URL&#8221; field.  Then put &#8220;default&#8221; in the &#8220;branch&#8221; field and set up the rest of the job to build/test your code (an exercise left to the reader).</p>
]]></content:encoded>
			<wfw:commentRss>http://naleid.com/blog/2009/12/21/hooking-up-hudson-to-your-bitbucket-mercurial-account/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
