The current version of the shelve plugin does not support shelving multiple projects. This can be a pain if you have a large Jenkins deployment. Luckily, it is possible to shelve multiple projects using a simple bash script.
If you have the jenkis-cli jar on your system, this can be can in two steps:
- First generate a list of jobs to shelve:
1 |
java -jar jenkins-cli.jar -noCertificateCheck -http -user <your user> -i <key> -s http://jenkins.host.com:8080/ list-jobs | grep jobs-I-want-to-remove > ~/tmp/shelve-list.txt |
- Iterate over the list to shelve the projects:
1 |
i=0 ; for job in $(cat ~/tmp/shelve-list.txt) ; do curl -u <user>:<password> -X POST -D "{}" http://jenkins.host.com:8080/job/$job/shelve/shelveProject ; ((i++)) ; [[ $i == 10 ]] && echo "Waiting ... " && sleep 10 && export i=0; done |
This script uses a small delay between every couple shelve requests. This is useful if your jobs contain a lot of data and Jenkins will take too long to shelve them.