Python Jenkins is a library for the remote API of the Jenkins continuous integration server. It is useful for creating and managing jobs as well as build nodes.
Example usage:
j = jenkins.Jenkins('http://your_url_here', 'username', 'password')
j.get_jobs()
j.create_job('empty', jenkins.EMPTY_CONFIG_XML)
j.disable_job('empty')
j.copy_job('empty', 'empty_copy')
j.enable_job('empty_copy')
j.reconfig_job('empty_copy', jenkins.RECONFIG_XML)
j.delete_job('empty')
j.delete_job('empty_copy')
# build a parameterized job
j.build_job('api-test', {'param1': 'test value 1', 'param2': 'test value 2'})
Python Jenkins development is hosted on Launchpad: https://launchpad.net/python-jenkins
pip:
pip install python-jenkins
easy_install:
easy_install python-jenkins
Ubuntu Oneiric or later:
apt-get install python-jenkins
General exception type for jenkins-API-related failures.
Create handle to Jenkins instance.
All methods will raise JenkinsException on failure.
| Parameters: |
|
|---|
Get list of jobs running. Each job is a dictionary with ‘name’, ‘url’, and ‘color’ keys.
| Returns: | list of jobs, [ { str: str} ] |
|---|
| Parameters: |
|
|---|---|
| Returns: | True if Jenkins job exists |
Trigger build job.
| Parameters: |
|
|---|
Get URL to trigger build job. Authenticated setups may require configuring a token on the server side.
| Parameters: |
|
|---|---|
| Returns: | URL for building job |
Create a new Jenkins job
| Parameters: |
|
|---|
Copy a Jenkins job
| Parameters: |
|
|---|
Delete Jenkins job permanently.
| Parameters: |
|
|---|
Enable Jenkins job.
| Parameters: |
|
|---|
Disable Jenkins job. To re-enable, call Jenkins.enable_job().
| Parameters: |
|
|---|
Get configuration XML of existing Jenkins job.
| Parameters: |
|
|---|---|
| Returns: | Job configuration XML |
Get job information dictionary.
| Parameters: |
|
|---|---|
| Returns: | dictionary of job information |
Print out job info in more readable format
Change configuration of existing Jenkins job. To create a new job, see Jenkins.create_job().
| Parameters: |
|
|---|
Get node information dictionary
| Parameters: |
|
|---|---|
| Returns: | Dictionary of node info, dict |
| Parameters: |
|
|---|---|
| Returns: | True if Jenkins node exists |
| Parameters: |
|
|---|
Delete Jenkins node permanently.
| Parameters: |
|
|---|
| Returns: | list of job dictionaries, [dict] |
|---|
Example:
>>> queue_info = j.get_queue_info()
>>> print(queue_info[0])
{u'task': {u'url': u'http://your_url/job/my_job/', u'color': u'aborted_anime', u'name': u'my_job'}, u'stuck': False, u'actions': [{u'causes': [{u'shortDescription': u'Started by timer'}]}], u'buildable': False, u'params': u'', u'buildableStartMilliseconds': 1315087293316, u'why': u'Build #2,532 is already in progress (ETA:10 min)', u'blocked': True}
Get information on this Master. This information includes job list and view information.
| Returns: | dictionary of information about Master, dict |
|---|
Example:
>>> info = j.get_info()
>>> jobs = info['jobs']
>>> print(jobs[0])
{u'url': u'http://your_url_here/job/my_job/', u'color': u'blue', u'name': u'my_job'}