安装python-jenkins
pip3 install python-jenkins
登录jenkins,获取Jenkins版本
import jenkins
import json
jenkins_server = 'http://192.168.41.29:8080'
user_id = '5010905'
api_token = '1130c5e4c3968bfe4c64edb9f0a8ecc5c5'
server = jenkins.Jenkins(jenkins_server, username=user_id, password=api_token)
user = server.get_whoami()
version = server.get_version()
print('Hello %s from Jenkins %s ' %(user['fullName'], version))
job_name = 'dev-vcloud-bpm-api'
job_info = server.get_job_info(job_name)
job_info_json = json.dumps(job_info, sort_keys=True, indent=4)
print(job_info_json)