Jenkins is the market leading continuous integration system, originally created by Kohsuke Kawaguchi. This API makes Jenkins even easier to use by providing an easy to use conventional python interface.

Jenkins (and It’s predecessor Hudson) are fantastic projects - but they are somewhat Java-centric. Thankfully the designers have provided an excellent and complete REST interface. This library wraps up that interface as more conventional python objects in order to make most Jenkins oriented tasks simpler.

This library can help you:

Query the test-results of a completed build

Get a objects representing the latest builds of a job

Search for artifacts by simple criteria

Block until jobs are complete

Install artifacts to custom-specified directory structures

Username/password auth support for jenkins instances with auth turned on

Egg-files for this project are hosted on PyPi. Most Python users should be able to use pip or setuptools to automatically install this project.

Most users can do the following:

pip install jenkinsapi

Or..

easy_install jenkinsapi
* In Jenkins > 1.518 you will need to disable "Prevent Cross Site Request Forgery exploits".
* Remember to set the Jenkins Location in general settings - Jenkins' REST web-interface will not work if this is set incorrectly.

When used with the Git source-control system line 20 will print out something like ‘8b4f4e6f6d0af609bb77f95d8fb82ff1ee2bba0d’ - which looks suspiciously like a Git revision number.

Note: As of Jenkins version 1.426, and above, an API token can be specified instead of your real password, while authenticating the user against the Jenkins instance. Refer to the the Jenkis wiki page [Authenticating scripted clients](https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients) for details about how a user can generate an API token. Once you have obtained an API token you can pass the API token instead of real password while creating an Jenkins server instance using Jenkins API.

JenkinsAPI is a pure-python project and can be improved with almost any programmer’s text-editor or IDE. I’d recomend the following project layout which has been shown to work with both SublimeText2 and Eclipse/PyDev

Make sure that pip and virtualenv are installed on your computer. On most Linux systems these can be installed directly by the OS package-manager.

Create a new virtualenv for the project:

virtualenvjenkinsapi

Change to the new directory and check out the project code into the src subdirectory:

cdjenkinsapigitclonehttps://github.com/salimfadhley/jenkinsapi.gitsrc

Activate your jenkinsapi virtual environment:

cdbinsourceactivate

Install the jenkinsapi project in ‘developer mode’ - this step will automatically download all of the project’s dependancies:

cd../srcpythonsetup.pydevelop

Test the project - this step will automatically download and install the project’s test-only dependancies. Having these installed will be helpful during development:

pythonsetup.pytest

Set up your IDE/Editor configuration - the misc folder contains configuration for Sublime Text 2. I hope in time that other developers will contribute useful configurations for their favourite development tools.