Skip to content

Instantly share code, notes, and snippets.

@9to6
Last active September 23, 2019 14:50
Show Gist options
  • Save 9to6/3b62786e400d39c771be2d41adac4dc7 to your computer and use it in GitHub Desktop.
Save 9to6/3b62786e400d39c771be2d41adac4dc7 to your computer and use it in GitHub Desktop.
for migration jenkins jobs
#!/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