See examples at Example usage
General exception type for jenkins-API-related failures.
A special exception to call out the case of receiving a 404.
A special exception to call out the case receiving an empty response.
A special exception to call out the case of a broken HTTP response.
Simple implementation of HTTP Basic Authentication.
Returns the ‘Authentication’ header value.
Create handle to Jenkins instance.
All methods will raise JenkinsException on failure.
Parameters: |
|
---|
Get job information dictionary.
Parameters: |
|
---|---|
Returns: | dictionary of job information |
Parameters: |
|
---|---|
Returns: | List of jobs info, list |
Return the name of a job using the API.
That is roughly an identity method which can be used to quickly verify a job exist or is accessible without causing too much stress on the server side.
Parameters: | name – Job name, str |
---|---|
Returns: | Name of job or None |
Print out job info in more readable format.
Utility routine for opening an HTTP request to a Jenkins server.
This should only be used to extends the Jenkins API.
Get build information dictionary.
Parameters: |
|
---|---|
Returns: | dictionary of build information, dict |
Example:
>>> j = Jenkins()
>>> next_build_number = j.get_job_info('build_name')['next_build_number']
>>> output = j.build_job('build_name')
>>> from time import sleep; sleep(10)
>>> build_info = j.get_build_info('build_name', next_build_number)
>>> print(build_info)
{u'building': False, u'changeSet': {u'items': [{u'date': u'2011-12-19T18:01:52.540557Z', u'msg': u'test', u'revision': 66, u'user': u'unknown', u'paths': [{u'editType': u'edit', u'file': u'/branches/demo/index.html'}]}], u'kind': u'svn', u'revisions': [{u'module': u'http://eaas-svn01.i3.level3.com/eaas', u'revision': 66}]}, u'builtOn': u'', u'description': None, u'artifacts': [{u'relativePath': u'dist/eaas-87-2011-12-19_18-01-57.war', u'displayPath': u'eaas-87-2011-12-19_18-01-57.war', u'fileName': u'eaas-87-2011-12-19_18-01-57.war'}, {u'relativePath': u'dist/eaas-87-2011-12-19_18-01-57.war.zip', u'displayPath': u'eaas-87-2011-12-19_18-01-57.war.zip', u'fileName': u'eaas-87-2011-12-19_18-01-57.war.zip'}], u'timestamp': 1324317717000, u'number': 87, u'actions': [{u'parameters': [{u'name': u'SERVICE_NAME', u'value': u'eaas'}, {u'name': u'PROJECT_NAME', u'value': u'demo'}]}, {u'causes': [{u'userName': u'anonymous', u'shortDescription': u'Started by user anonymous'}]}, {}, {}, {}], u'id': u'2011-12-19_18-01-57', u'keepLog': False, u'url': u'http://eaas-jenkins01.i3.level3.com:9080/job/build_war/87/', u'culprits': [{u'absoluteUrl': u'http://eaas-jenkins01.i3.level3.com:9080/user/unknown', u'fullName': u'unknown'}], u'result': u'SUCCESS', u'duration': 8826, u'fullDisplayName': u'build_war #87'}
Returns: | list of job dictionaries, [dict] |
---|
>>> j = Jenkins()
>>> 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}
Cancel a queued build.
Parameters: | id – Jenkins job id number for the build, int |
---|
Get information on this Master.
This information includes job list and view information.
Returns: | dictionary of information about Master, dict |
---|
Example:
>>> j = Jenkins()
>>> 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'}
Get the version of this Master.
Returns: | This master’s version number str |
---|
Example:
>>> j = Jenkins()
>>> info = j.get_version()
>>> print info
>>> 1.541
Get all installed plugins information on this Master.
This method retrieves information about each plugin that is installed on master.
Parameters: | depth – JSON depth, int |
---|---|
Returns: | info on all plugins [dict] |
Example:
>>> j = Jenkins()
>>> info = j.get_plugins_info()
>>> print(info)
[{u'backupVersion': None, u'version': u'0.0.4', u'deleted': False,
u'supportsDynamicLoad': u'MAYBE', u'hasUpdate': True,
u'enabled': True, u'pinned': False, u'downgradable': False,
u'dependencies': [], u'url':
u'http://wiki.jenkins-ci.org/display/JENKINS/Gearman+Plugin',
u'longName': u'Gearman Plugin', u'active': True, u'shortName':
u'gearman-plugin', u'bundled': False}, ..]
Get an installed plugin information on this Master.
This method retrieves information about a speicifc plugin. The passed in plugin name (short or long) must be an exact match.
Parameters: |
|
---|---|
Returns: | a specific plugin dict |
Example:
>>> j = Jenkins()
>>> info = j.get_plugin_info("Gearman Plugin")
>>> print(info)
{u'backupVersion': None, u'version': u'0.0.4', u'deleted': False,
u'supportsDynamicLoad': u'MAYBE', u'hasUpdate': True,
u'enabled': True, u'pinned': False, u'downgradable': False,
u'dependencies': [], u'url':
u'http://wiki.jenkins-ci.org/display/JENKINS/Gearman+Plugin',
u'longName': u'Gearman Plugin', u'active': True, u'shortName':
u'gearman-plugin', u'bundled': False}
Get list of jobs running.
Each job is a dictionary with ‘name’, ‘url’, and ‘color’ keys.
Returns: | list of jobs, [ { str: str} ] |
---|
Copy a Jenkins job
Parameters: |
|
---|
Rename an existing Jenkins job
Parameters: |
|
---|
Delete Jenkins job permanently.
Parameters: | name – Name of Jenkins job, str |
---|
Enable Jenkins job.
Parameters: | name – Name of Jenkins job, str |
---|
Disable Jenkins job.
To re-enable, call Jenkins.enable_job().
Parameters: | name – Name of Jenkins job, str |
---|
Check whether a job exists
Parameters: | name – Name of Jenkins job, str |
---|---|
Returns: | True if Jenkins job exists |
Get the number of jobs on the Jenkins server
Returns: | Total number of jobs, int |
---|
Raise an exception if a job does not exist
Parameters: |
|
---|---|
Throws: | JenkinsException whenever the job does not exist |
Create a new Jenkins job
Parameters: |
|
---|
Get configuration of existing Jenkins job.
Parameters: | name – Name of Jenkins job, str |
---|---|
Returns: | job configuration (XML format) |
Change configuration of existing Jenkins job.
To create a new job, see Jenkins.create_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 |
Trigger build job.
Parameters: |
|
---|
Stop a running Jenkins build.
Parameters: |
|
---|
Get node information dictionary
Parameters: |
|
---|---|
Returns: | Dictionary of node info, dict |
Check whether a node exists
Parameters: | name – Name of Jenkins node, str |
---|---|
Returns: | True if Jenkins node exists |
Raise an exception if a node does not exist
Parameters: |
|
---|---|
Throws: | JenkinsException whenever the node does not exist |
Delete Jenkins node permanently.
Parameters: | name – Name of Jenkins node, str |
---|
Disable a node
Parameters: |
|
---|
Enable a node
Parameters: | name – Jenkins node name, str |
---|
Create a node
Parameters: |
|
---|
Get the configuration for a node.
Parameters: | name – Jenkins node name, str |
---|
Change the configuration for an existing node.
Parameters: |
|
---|
Get build console text.
Parameters: |
|
---|---|
Returns: | Build console output, str |