当前位置:网站首页>Python 3 operates the Jenkins module API

Python 3 operates the Jenkins module API

2020-11-06 22:38:38 Leaf blade

#coding=utf-8
import json
from time import sleep
import jenkins

#  Set up jenkins Connection timeout 5 second 
server = jenkins.Jenkins('http://192.168.xxx.xxx:8088',
                         username='root',
                         password='adminadmin',
                         timeout=5)


jenkins_job = 'ZEP-BACKEND-JAVA'
arg_dic = {
    'git_url': 'http://192.168.xxx.xxx/ZEP-BACKEND/ZEP-BACKEND-JAVA.git',
    'branch_build': 'master',
    'package_name': 'javademo-1.0.jar',
    'app_name': 'ZEP-BACKEND-JAVA',
    'deploy_version': '2020-1102-2232-24BP',
    'dir_build_file': 'javademo',
    'zip_package_name': 'javademo-1.0.tar.gz',
    }

next_build_number = server.get_job_info(jenkins_job)['nextBuildNumber']
server.build_job(jenkins_job, arg_dic)
print(next_build_number)
sleep(10)
build_info = server.get_build_info(jenkins_job, next_build_number)
print(json.dumps(build_info, sort_keys=True,
                 indent=4, separators=(',', ':')))

版权声明
本文为[Leaf blade]所创,转载请带上原文链接,感谢