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://codecov.io/gh/pycontribs/jenkinsapi/branch/master/graph/badge.svg

About this library

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

Jenkins (and its predecessor Hudson) are useful projects for automating common development tasks (e.g. unit-testing, production batches) - but they are somewhat Java-centric. | Jenkinsapi makes scripting Jenkins tasks a breeze by wrapping the REST api into familiar python objects. | Here is a list of some of the most commonly used functionality

  • Add, remove, and query Jenkins jobs

  • Control pipeline execution
    • 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

  • Artifact management
    • Search for artifacts by simple criteria

    • Install artifacts to custom-specified directory structures

  • Search for builds by source code revision

  • Create, destroy, and monitor
    • Build nodes (Webstart and SSH slaves)

    • Views (including nested views using NestedViews Jenkins plugin)

    • Credentials (username/password and ssh key)

  • Authentication support for username and password

  • Manage jenkins and plugin installation

Full library capabilities are outlined in the Documentation

Known issues

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

For other issues, please refer to the support URL

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

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:

from jenkinsapi.jenkins import Jenkins
J = Jenkins('http://localhost:8080')
print(J.version) # 1.542
print(J.keys()) # foo, test_jenkinsapi
print(J.get('test_jenkinsapi')) # <jenkinsapi.job.Job test_jenkinsapi>
print(J.get('test_jenkinsapi').get_last_good_build()) # <jenkinsapi.build.Build test_jenkinsapi #77>

More examples available on Github

Testing

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

uv sync
uv run pytest -sv --cov=jenkinsapi --cov-report=term-missing --cov-report=xml jenkinsapi_tests

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

uv venv
uv python install
uv run pytest -sv --cov=jenkinsapi --cov-report=term-missing --cov-report=xml jenkinsapi_tests

Development

  • Make sure that you have Java installed. Jenkins will be automatically downloaded and started during tests.

  • Create virtual environment for development

  • Install package in development mode

uv sync
  • Make your changes, write tests and check your code

uv run pytest -sv

Python versions

The project has been tested against Python versions:

  • 3.8 - 3.13

Jenkins versions

Project tested on both stable (LTS) and latest Jenkins versions.

Project Contributors

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

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.3.14.tar.gz (57.6 kB view details)

Uploaded Source

Built Distribution

jenkinsapi-0.3.14-py3-none-any.whl (70.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jenkinsapi-0.3.14.tar.gz
  • Upload date:
  • Size: 57.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for jenkinsapi-0.3.14.tar.gz
Algorithm Hash digest
SHA256 1be5a3d60bb97b8fd5a9d9d4477e2201e07e4725a7d42c0eb16846bb879e4b97
MD5 232beacbaf42d30d6945a4c155a0b025
BLAKE2b-256 f1d8a276dad87ca55fe6c3293680c2fdb6045c91f6073be3bec19e7c07824374

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jenkinsapi-0.3.14-py3-none-any.whl
  • Upload date:
  • Size: 70.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for jenkinsapi-0.3.14-py3-none-any.whl
Algorithm Hash digest
SHA256 9481701bb81dcb6edf699e30ec496b57aff37212eab40bfba717efd8ccc2aa0b
MD5 e5c9365d13d92a7141f30263f216550e
BLAKE2b-256 f44d8f81e3b2a1b8f773770976ff275bc211f6e4a741b213b957f272b181bd11

See more details on using hashes here.

Supported by

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