(高级)通过API 更改jenkins 的job 配置

2018-12-20  本文已影响0人  devttao

实际上这不属于jenkins 的高级 用法, 暂且放在这里_

获取当前配置

curl -X GET http://developer:developer@localhost:8080/job/test/config.xml -o mylocalconfig.xml

更改配置内容

mylocalconfig.xml 修改相应的配置项, 如参数增加一个选项:


image.png

or

# n;n; find the keywords and add one more line in the file
sed -i -e "/# Adjust #/{n;n;s|\$|\n              <string>NAME<\/string>|}" modifi.xml

推送更新更改后的配置

curl -X POST http://developer:developer@localhost:8080/job/test/config.xml --data-binary "@mymodifiedlocalconfig.xml"

注意: 一般情况下不建议这种方式直接更改jenkins 配置,万一改错conifg.xml,jenkins job 的配置就被破坏了,甚至jenkins整个挂掉。切记切记!
另: 备份很重要!_

上一篇 下一篇

猜你喜欢

热点阅读