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
- Job deletion operations fail unless Cross-Site scripting protection is disabled.
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
Both of these techniques can be combined with virtualenv to create an application-specific installation.
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.
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
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:
python -m venv ./.venv/jenkinsapi
source .venv/jenkinsapi/bin/activate
pip install -r requirements.txt
python setup.py test
- 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
pip install -r test-requirements.txt
- Make your changes, write tests and check your code
pytest -sv
The project has been tested against Python versions:
- 3.8 - 3.11
- 2.7 - last version compatible with Python 2.7 is tagged Py2 in repository and available on PyPi as version 0.3.13
Project tested on both stable (LTS) and latest Jenkins versions.
- Aleksey Maksimov (ctpeko3a@gmail.com)
- Salim Fadhley (sal@stodge.org)
- Ramon van Alteren (ramon@vanalteren.nl)
- Ruslan Lutsenko (ruslan.lutcenko@gmail.com)
- Cleber J Santos (cleber@simplesconsultoria.com.br)
- William Zhang (jollychang@douban.com)
- Victor Garcia (bravejolie@gmail.com)
- Bradley Harris (bradley@ninelb.com)
- Kyle Rockman (kyle.rockman@mac.com)
- Sascha Peilicke (saschpe@gmx.de)
- David Johansen (david@makewhat.is)
- Misha Behersky (bmwant@gmail.com)
Please do not contact these contributors directly for support questions! Use the GitHub tracker instead.
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.