问题
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.
- shut down Jenkins
- update job config.xml files
- 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