A Python API for accessing resources on a Jenkins continuous-integration server.
Project description
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, such as:
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 artifacts:
Search for artifacts by simple criteria
Install artifacts 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
For a full documentation spec of what this library supports see: http://jenkinsapi.readthedocs.io/en/latest/index.html
Python versions
The project has been tested against Python versions:
2.7
3.4
3.5
3.6
3.7
Jenkins versions
Project tested on both stable (LTS) and latest Jenkins versions.
Known issues
Job deletion operations fail unless Cross-Site scripting protection is disabled.
For other issues, please refer to the support URL below.
Important Links
Support and bug-reports: https://github.com/pycontribs/jenkinsapi/issues?direction=desc&sort=comments&state=open
Project source code: github: https://github.com/pycontribs/jenkinsapi
Project documentation: https://jenkinsapi.readthedocs.org/en/latest/
Releases: http://pypi.python.org/pypi/jenkinsapi
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/pycontribs/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
Development
Make sure that you have Java installed.
Create virtual environment for development
Install package in development mode
(venv) pip install -e .
(venv) pip install -r test-requirements.txt
Make your changes, write tests and check your code
(venv) tox
Project Contributors
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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jenkinsapi-0.3.9.tar.gz
.
File metadata
- Download URL: jenkinsapi-0.3.9.tar.gz
- Upload date:
- Size: 138.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf35b208fe05e65508f3b8bbb0f91d164b007632e27ebe5f54041174b681b696 |
|
MD5 | 5b78e41640c98c90fd89ca4ab01cb17f |
|
BLAKE2b-256 | cfd439bf077ceb60c742b0c1af4738b9ee50475db97ae57e76f6239456b5b624 |
File details
Details for the file jenkinsapi-0.3.9-py2.py3-none-any.whl
.
File metadata
- Download URL: jenkinsapi-0.3.9-py2.py3-none-any.whl
- Upload date:
- Size: 130.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7bd63096859a521fbc790f48842f030015cab5bcd98b4dd79a451dcd6f5bd94 |
|
MD5 | 36a122b6137d1ac2651cedfbaadebd89 |
|
BLAKE2b-256 | de42d966fff11505493e27676d3171f5955bedf8f3c6cdb26a72c18210974319 |