如何在多个 Jenkins 作业中大量添加构建后操作



主题是不言自明的。我想为许多 Jenkins 作业添加构建后操作,而不是逐个配置。我添加了Configuration Slicing插件,但如果我没记错的话,它不会修改构建后操作。有什么想法吗?

提前致谢

如果配置切片插件不能满足您的要求,那么您应该回退到 SED。

来自 Jenkins Issues:

你需要编写一个脚本来循环遍历你的 Jenkins 作业和 SED 值与新值,然后使用 POST https://support.cloudbees.com/hc/en-us/articles/218353308-How-to-update-job-config-files-using-the-REST-API-and-cURL

  1. 获取当前配置
    curl -X GET http://developer:developer@localhost:8080/job/test/config.xml -o 我的本地配置.xml

  2. 发布更新的配置
    卷曲 -X 开机自检 http://developer:developer@localhost:8080/job/test/config.xml --数据二进制"@mymodifiedlocalconfig.xml"

对于 Pos-build 操作是<publishers>...</publishers>之间的标记config.xml

最新更新