Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Backup up all Jenkins jobs as XML
#!/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