[Jenkins] Use python requests to programatically get and set Jenkins job configuration
来源:互联网 发布:瑜伽初学者 知乎 编辑:程序博客网 时间:2024/05/01 19:02
Jenkins provided a very nice REST api to interact. In Python, we can use requests
package. For simplicity, we are going to use password based authentication. For details on requests
package, please see its official documentation.
Get the job configuration
Get the configuration is real easy. Please replace jenkins_ip
,jenkins_port
,job_name
,username
,password
with your customized value.
import requestsurl = http://jenkins_ip:jenkins_port/job/job_name/config.xmlr = requests.get(url, auth=('username', 'password'))config = r.text
The config
is an unicode xml string of the job configuration.
Set the job configuration
To modify the job configuration, you can post the modified config
to the same url.
p = requests.post(url, data=config, auth=('username', 'password'))
Not there are two things you might need to pay attention to:
1. the url is url = http://jenkins_ip:jenkins_port/job/job_name/config.xml
, not url = http://jenkins_ip:jenkins_port/job/job_name
2. use the data
parameter, not the files
parameter. Reason is listed here.
- [Jenkins] Use python requests to programatically get and set Jenkins job configuration
- how to use jenkins
- jenkins read only job configuration plugin
- Get Jenkins job build queue length
- Jenkins + python(requests)做接口自动化测试
- How to setup Java Jenkins job
- Python-Jenkins 查询Job是否存在
- PercentRelativeLayout, how to set the height programatically
- Jenkins集成--构建job
- Jenkins迁移job
- Jenkins Job 自杀 groovy
- Jenkins Job Builder 配置文件
- Jenkins Job Backup
- Jenkins Job Http Api
- Jenkins-Requeue Job
- set https on Jenkins
- jenkins run job with p4
- Jenkins如何构建下一个job
- Codeforces 690C2 Brain Network (medium) (树的直径)
- 一个insert插入语句很慢的优化
- c++库
- 进程平均周转时间的计算
- linux命令追加信任列表
- [Jenkins] Use python requests to programatically get and set Jenkins job configuration
- delphiXE Implicit string cast from 'AnsiString' to 'string'
- 浅谈Java设计模式(十)桥接模式(Bridge)
- C语言断言(assert)小结
- Windows下配置R-FCN
- tomcat如何路由映射网址
- TopCoder SRM 694
- Xilinx FPGA上电时序分析与设计
- SCU2016-04 C题模拟