Skip to main content

A Python API for accessing resources on a Jenkins continuous-integration server.

Project description

https://badge.fury.io/py/jenkinsapi.png https://travis-ci.org/salimfadhley/jenkinsapi.png?branch=master https://landscape.io/github/salimfadhley/jenkinsapi/master/landscape.png Requirements Status

About this library

Jenkins is the market leading continuous integration system, originally created by Kohsuke Kawaguchi.

Jenkins (and It’s predecessor Hudson) are useful projects for automating common development tasks (e.g. unit-testing, production batches) - 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 many Jenkins oriented tasks easier to automate.

This library allows you to automate most common Jenkins operations using Python.

  • Ability to add/remove/query Jenkins jobs

  • Ability to execute jobs and:
    • Query the results of a completed build

    • Block until jobs are complete or run jobs asyncronously

    • Get objects representing the latest builds of a job

  • Work with build artefacts:
    • Search for artefacts by simple criteria

    • Install artefacts to custom-specified directory structures

  • Ability to search for builds by source code revision

  • Ability to add/remove/query:
    • Slaves (Webstart and SSH slaves)

    • Views (including nested views using NestedViews Jenkins plugin)

    • Credentials (username/password and ssh key)

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

  • Ability to script jenkins installation including plugins

Python versions

The project have been tested and working on Python 2.7, 3.3 and 3.4. It was tested previously on Python 2.6, so it may work on this version too.

Known issues

  • Job deletion operations fail unless Cross-Site scripting protection is disabled.

For other issues, please refer to the support URL below.

Installation

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.

Using Pip or Setuptools

Most users can do the following:

pip install jenkinsapi

Or:

easy_install jenkinsapi

Both of these techniques can be combined with virtualenv to create an application-specific installation.

Using your operating-system’s package manager

Ubuntu users can now use apt to install this package:

apt-get install python-jenkinsapi

Beware that this technique will get a somewhat older version of Jenkinsapi.

Example

JenkinsAPI is intended to map the objects in Jenkins (e.g. Builds, Views, Jobs) into easily managed Python objects:

>>> import jenkinsapi
>>> from jenkinsapi.jenkins import Jenkins
>>> J = Jenkins('http://localhost:8080')
>>> J.version
1.542
>>> J.keys() # Jenkins objects appear to be dict-like, mapping keys (job-names) to
['foo', 'test_jenkinsapi']
>>> J['test_jenkinsapi']
<jenkinsapi.job.Job test_jenkinsapi>
>>> J['test_jenkinsapi'].get_last_good_build()
<jenkinsapi.build.Build test_jenkinsapi #77>
...

More examples available on Github: https://github.com/salimfadhley/jenkinsapi/tree/master/examples

Testing

If you have installed the test dependencies on your system already, you can run the testsuite with the following command:

python setup.py test

Otherwise using a virtualenv is recommended. Setuptools will automatically fetch missing test dependencies:

virtualenv
source .venv/bin/active
(venv) python setup.py test

Project Contributors

Please do not contact these contributors directly for support questions! Use the GitHub tracker instead.

License

The MIT License (MIT): Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jenkinsapi-0.2.29.tar.gz (37.5 kB view details)

Uploaded Source

Built Distribution

jenkinsapi-0.2.29-py3-none-any.whl (53.6 kB view details)

Uploaded Python 3

File details

Details for the file jenkinsapi-0.2.29.tar.gz.

File metadata

  • Download URL: jenkinsapi-0.2.29.tar.gz
  • Upload date:
  • Size: 37.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jenkinsapi-0.2.29.tar.gz
Algorithm Hash digest
SHA256 e44a6ef29499a6000bcba748e9313b6ba1e00c7919f859dda0c29fb0742b5379
MD5 0b290e612f285f10a6653d319c020c48
BLAKE2b-256 7d772f8ea367e3e366e86ef946d96cd8130876b5fe8f92da0244b089db00b79a

See more details on using hashes here.

File details

Details for the file jenkinsapi-0.2.29-py3-none-any.whl.

File metadata

File hashes

Hashes for jenkinsapi-0.2.29-py3-none-any.whl
Algorithm Hash digest
SHA256 d99cc6f76b0924e5a481bbe630764db2f23026e86cb66e4daa7a34fb393690e1
MD5 9ffaffa3dfa865ae55845a1d7f8ac308
BLAKE2b-256 0641f5c4fc5c8532f05022f40cc8904fea860eb1e9670b9549baef0de177f0bb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page