pip install jenkinsapi
Jenkins is the market leading continuous integration system.
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
"""Get job details of each job that is running on the Jenkins instance"""
def get_job_details():
# Refer Example #1 for definition of function 'get_server_instance'
server = get_server_instance()
for job_name, job_instance in server.get_jobs():
print 'Job Name:%s' % (job_instance.name)
print 'Job Description:%s' % (job_instance.get_description())
print 'Is Job running:%s' % (job_instance.is_running())
print 'Is Job enabled:%s' % (job_instance.is_enabled())
def disable_job():
"""Disable a Jenkins job"""
# Refer Example #1 for definition of function 'get_server_instance'
server = get_server_instance()
job_name = 'nightly-build-job'
if (server.has_job(job_name)):
job_instance = server.get_job(job_name)
job_instance.disable()
print 'Name:%s,Is Job Enabled ?:%s' % (job_name,job_instance.is_enabled())
Use the call job_instance.enable()
to enable a Jenkins Job.
- Job deletion operations fail unless Cross-Site scripting protection is disabled.
For other issues, please refer to the support URL
- 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
The project has been tested against Python versions:
- 3.8 - 3.13
Project tested on both stable (LTS) and latest Jenkins versions.
- Aleksey Maksimov ([email protected])
- Salim Fadhley ([email protected])
- Ramon van Alteren ([email protected])
- Ruslan Lutsenko ([email protected])
- Cleber J Santos ([email protected])
- William Zhang ([email protected])
- Victor Garcia ([email protected])
- Bradley Harris ([email protected])
- Kyle Rockman ([email protected])
- Sascha Peilicke ([email protected])
- David Johansen ([email protected])
- Misha Behersky ([email protected])
- Clinton Steiner ([email protected])
Please do not contact these contributors directly for support questions! Use the GitHub tracker instead.