Last active
September 23, 2019 14:50
-
-
Save 9to6/3b62786e400d39c771be2d41adac4dc7 to your computer and use it in GitHub Desktop.
for migration jenkins jobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
JENKINS_URL=$1 | |
VIEW=$2 | |
if [ -z "$1" ] | |
then | |
echo "Need to JENKINS URL for first argument" | |
exit 1 | |
fi | |
if [ -z "$2" ] | |
then | |
echo "No argument supplied, will use default View name is 'all'" | |
VIEW=all | |
fi | |
mkdir -p ./jobs | |
java -jar jenkins-cli.jar -s $JENKINS_URL list-jobs "$VIEW" | | |
while read line | |
do | |
echo "$line" | |
PWD=$(pwd) | |
bash -c "java -jar jenkins-cli.jar -s $JENKINS_URL get-job "$line" > "$PWD/jobs/$line".xml" & | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://staxmanade.com/2015/01/how-to-migrate-a-jenkins-job-to-new-jenkins-server/