Add Jenkins Groovy Postbuild step to all jobs

拜拜、爱过 提交于 2019-12-13 01:50:03

问题


How can the same Jenkins Groovy Postbuild Plugin step be added to all jobs? We have 50+ jobs, so it is too hard to copy-paste the link to desired groovy code to every job.


回答1:


I usually do similar mass changes by updating the config.xml of the effected jobs. Every good editoru should have a search and replace function that works on files. use the following workflow.

  1. shut down Jenkins
  2. update job config.xml files
  3. start up Jenkins

There are other possible workflows like the following 1. update job config.xml files 2. reload config

However, with the second option I don't know how it effects if a job is running while you reload a config.




回答2:


The following script requires the Jenkins Groovy and Groovy postbuild plugins to work. It will add a Jenkins Groovy postbuild publisher to all jobs:

https://gist.github.com/genericpenguin/9ac1b84ed7a145b3b6dd

Change the view from 'All' to some other view for testing. We use it for mass changes and it works fine. Only caveat is that postbuild groovy script must reside on Jenkins master. This can be easily changed in the script if it is short (like a script loader).



来源:https://stackoverflow.com/questions/20213693/add-jenkins-groovy-postbuild-step-to-all-jobs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!