通过python-jenkins 获取job的输出日志
使用方法:
get_build_console_output
(name, number)
Get build console text.
Parameters: |
|
---|---|
Returns: |
Build console output, |
示例:
import jenkins,requests #定义远程的jenkins master server 的url以及Port jenkins_server_url = 'http://10.2.1.92:8080/jenkins/' #定义用户的userid 和 apitoken(在jenkins中生成) user_id = 'admin' api_token = '11d8c79994b1e6d554c857b1d96fcf4dfe' #测试服务器 server = jenkins.Jenkins(jenkins_server_url,username=user_id,password=api_token) jobName1='autotest' joblog=server.get_build_console_output(jobName1,139) print(joblog)
输出结果(str):