PyJen - Jenkins CI Python library¶
PyJen is an extensible, user and developer friendly Python interface to the Jenkins CI tool, wrapping the features exposed by the standard REST API using Pythonic objects and functions. Tested against the latest 2.x and 3.x versions of CPython and the latest trunk and LTS editions of the Jenkins REST API, we endeavor to provide a stable, reliable tool for a variety of users.
With an intuitive and well thought out interface, PyJen offers anyone familiar with the Python programming language an easy way to manage Jenkins dashboards from a simple command prompt. All core primitives of Jenkins, including views, jobs and builds are easily accessible and can be loaded, analyzed and even modified or created via simple Python commands.
Comments, suggestions and bugs may be reported to the project maintainer
Quick Start Guide¶
First, and most obviously, you must have Python installed on your system. For details specific to your OS we recommend seeing Python’s website. We recommend using the latest version of Python 2.x / 3.x for best results.
Next, we recommend that you install the pip package manager as described here. If you are using newer editions of Python (3.x), or if you are using certain Linux distributions / packages you likely already have this tool installed. You can confirm this by running the following command:
# pip --version
which should result in output that looks something like this:
pip 8.0.2 from C:\Python34x64\lib\site-packages (python 3.4)
Install PyJen directly from PyPI using PIP:
# pip install pyjen
4. import the pyjen module and start scripting! Here is a short example that shows how you can get the name of the default view from a Jenkins instance:
>>> from pyjen.jenkins import Jenkins >>> jenkins_obj = Jenkins("http://localhost:8080", ('username', 'passwd')) >>> default_view = jenkins_obj.default_view >>> print(default_view.name)