CIHowto

How to build and test this project with Jenkins

Install Jenkins, a Continuous Integration (CI) server

See this link to get Jenkins in a suitable manner

NB using the ubuntu/debian package, I found I had to give the new user 'jenkins' some default Git credentials when dealing with GitHub:

# su jenkins
$ git config --global user.name "Ben's JenkinsBot"
$ git config --global user.email "somemailaccount@foo.com"

Adding Plugins

  • Navigate to http://localhost:8080 and click on "Manage Jenkins" and then "Manage Plugins"
  • Required plugins to add:
    • For Hg, look for -> "Jenkins Mercurial plugin" This plugin integrates Mercurial SCM with Hudson. It includes repository browsing support for hg serve/hgweb, Google Code, and Bitbucket. Features include guaranteed clean builds, named branch support, Forest extension support, module lists, Mercurial tool installation, and automatic caching.
    • For Git -> "Jenkins GIT plugin" This plugin integrates GIT with Jenkins.
    • And for SVN -> "Subversion Plugin"
    • "Python Plugin" Adds the ability to execute python scripts as build steps.
  • Optional, but useful/fun plugins:
    • "Jenkins Continuous Integration game": The continuous integration build game.
    • "Hudson Amazon EC2 plugin": This plugin integrates Hudson with Amazon EC2 or anything implementing the EC2 API's such as an Ubuntu.
    • "GitHub plugin" This plugin integrates GitHub to Jenkins.
    • "Performance plugin" (Adds graphs) This plugin integrates JMeter reports and the JUnit reports to Hudson.

Adding a project as a Jenkins 'Job'

  • Go to http://localhost:8080
  • Click 'New Job'
  • Label the job with the project name and select the "Build a free-style software project" and click on 'Ok'
  • Enter the desired title, description information to make the Jenkins report more informative.
  • In the Source Code Management section, choose the right option for the project:

Mercurial

  • Leave the 'Mercurial Version' set to '(default)' - NB mercurial must be installed to do this... :)
  • In the repository URL, put in the project URL, something like "https://bitbucket.org/beno/python-sword2" for example, and add the names of the branches you wish for the CI server to test. 'default' is a good one to add.

Git

  • Find the 'Read-only' URL for your git repository, for example 'git:github.com/benosteen/checkm.git', and add this as the 'URL of repository'
  • Add in the branches to build as desired ('master' is a good start)

Build Triggers

This can be left alone, but 'Build periodically' is quite a useful option. The web UI for this is notably poor as you have to enter it in by hand in its own format which is the same as for a cron job, for example:

15 18 * * *

Build

At the most basic, you can run the testsuite for the project you are pulling from its repo. This can be added as a 'Shell command' in the Build step.

For example, using 'nose' to run a testsuite and to output its results into a JUnit-compatible log file ('nosetests.xml' by default.)

bash -l -c "nosetests tests --with-xunit"

Using tox, this can be made to be much more sophisticated with ease, grabbing all the dependancies, building it in a clean environment, and so on. See the Tox section for more details on how to set this up.

bash -l -c "tox"

Post-Build Actions

Check the "Publish JUnit test result report" option and enter 'nosetests.xml' in the textbox that appears.

(If you are playing the CI game, you must check the option here for the points to count :))

You should be able to save the configuration and run the job for the first time now:

Running The Job

  • Go to your Dashboard and select the job you have just configured.
  • Click on the "Build now" option that appears and you should see the progress bar appear underneath.
  • Make sure that the Test Results are being retrieved by clicking on the timestamped build report option that should have appeared after you have built the project, and checking to see if the test results report is available. (The icon is that of a clipboard)

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.