Skip to content

Using Leiningen with the Jenkins CI server

dcj edited this page Apr 15, 2011 · 4 revisions

Here is how I (dcj) install Leiningen in the Jenkins CI server, and use it to build my Clojure projects.

I'm not claiming this is the only way to do so, or the best, but it documents how I have gotten this to work fairly well. I am very interested in ideas/suggestions about how to do this better....

I am working with another developer to produce an Leiningen plugin for Jenkins, here is the requirements document. Maybe by May or June (2011) this will be available.

In the mean time, here is how I install and use Leiningen with Jenkins using existing Jenkins features and plugins:

First I create a Jenkins job that downloads and installs Leiningen into the Jenkins workspace.

Next I configure how to get the stable release of Leiningen from GitHub:

And how often to poll for new versions:

Then I set up environment variables for this job.

I am building on Solaris, so I need to make sure /usr/ucb in on my path so lein can find whoami. In addition, Leiningen puts jar files into $HOME/.lein, so I have found it helpful to make sure $HOME is defined. Next I configure how to install Leiningen:

Now that the install is done, archive the results:

OK, so now Leiningen should be downloaded, installed, and available for use, here is how I access lein when configuring a Clojure build job in Jenkins, first define any important environment variables:

Then, the first, (or one of the early) build steps should be to "Copy Artifacts From Another Project", and configure it to copy the lein script you downloaded previously into the workspace of this new project (I put it in ./bin):

Subsequent build steps can be "Execute Shell", and then just issue the lein "target" command(s) you want.

Clone this wiki locally