python-jenkins/doc/source/example.rst
Brandon Leonard cabb95d873 Creates ability to work with views in jenkins
This patch allows users to create, delete, reconfigure, and list views in
Jenkins. It is very similar to the protocols for working with jobs and has the
same code structure and format.

Change-Id: I79c557520cc9a417399a1a18df0f57da6904ab0e
2015-07-06 12:14:26 +02:00

940 B

Example usage

Example usage:

import jenkins
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')

j.get_views()
j.create_view('EMPTY', jenkins.EMPTY_VIEW_CONFIG_XML)
j.view_exists('EMPTY')
j.delete_view('EMPTY')

# build a parameterized job
# requires setting up api-test job to accept 'param1' & 'param2'
j.build_job('api-test', {'param1': 'test value 1', 'param2': 'test value 2'})
last_build_number = j.get_job_info('api-test')['lastCompletedBuild']['number']
build_info = j.get_job_info('api-test', last_build_number)
print(build_info)

Look at the api for more details.