Last active
April 6, 2017 15:41
-
-
Save stefancrain/514526e2665dd125a9311600ca9d36f7 to your computer and use it in GitHub Desktop.
Backup up all Jenkins jobs as XML
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 | |
HOST="JENKINS_URL" | |
PORT="8443" | |
URL="http://USERNAME:APIKEY@$HOST:$PORT" | |
folder=$(date +%Y%m%d-%H%M%S) | |
mkdir -p "$HOST/$folder" | |
while read job | |
do | |
echo "Job: '$job'"; | |
java -jar ~/Downloads/jenkins-cli.jar -s "$URL" get-job "$job" > "$HOST/$folder/$job".xml | |
done < <(java -jar ~/Downloads/jenkins-cli.jar -s "$URL" list-jobs 2> /dev/null) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment