Python jenkinsapi tutorial (1)

User API
This module is a collection of useful advanced functions that can automate common tasks. Many of these functions are designed to be exposed to the command line, so they have simple string parameters.

Wait for all tasks to complete:

jenkinsapi.api.block_until_complete(jenkinsurl, jobs, maxwait=12000, interval=30, raise_on_timeout=True, username=None, password=None, ssl_verify=True)

Find all newly built jobs:

jenkinsapi.api.get_artifacts(jenkinsurl, jobid=None, build_no=None, username=None, password=None, ssl_verify=True)

Query the result of the jenkins task by build number:

jenkinsapi.api.get_build(jenkinsurl, jobname, build_no, username=None, password=None, ssl_verify=True)

Get the latest build results from the jenkins task:

jenkinsapi.api.get_latest_build(jenkinsurl, jobname, username=None, password=None, ssl_verify=True)

jenkinsapi.api.get_latest_complete_build(jenkinsurl, jobname, username=None, password=None, ssl_verify=True)

jenkinsapi.api.get_latest_test_results(jenkinsurl, jobname, username=None, password=None, ssl_verify=True)

Return to View according to the provided URL. Easy to nest views.

jenkinsapi.api.get_nested_view_from_url(url, username=None, password=None, ssl_verify=True)

jenkinsapi.api.get_view_from_url(url, username=None, password=None, ssl_verify=True)

Convenient way to find the latest completed version of a task and save it to the target directory. If it does not exist, the directory is automatically created:

jenkinsapi.api.grab_artifact(jenkinsurl, jobid, artifactid, targetdir, username=None, password=None, strict_validation=False, ssl_verify=True)

Install and build:

jenkinsapi.api.install_artifacts(artifacts, dirstruct, installdir, basestaticurl, strict_validation=False)

Search for the build with the task whose name matches the provided regular expression in the entire history of the hudson job. Only return the task.

@param jenkinsurl: the basic URL of the jenkins server @param jobid: the name of the job we want to search through @paramartifact RegExp: a compiled regular expression object

(Not re-string)
@param username: Jenkins login username, optional @param password: Jenkins login password, optional

jenkinsapi.api.search_artifact_by_regexp(jenkinsurl, jobid, artifactRegExp, username=None, password=None, ssl_verify=True

Search the list of build names in the entire history of jenkin job. If same_build is true, ensure that all artifacts are from the same build of the job

jenkinsapi.api.search_artifacts(jenkinsurl, jobid, artifact_ids=None, username=None, password=None, ssl_verify=True)

 

Published 59 original articles · 69 praises · 270,000+ views

Guess you like

Origin blog.csdn.net/pansaky/article/details/102938766