Skip to content

Instantly share code, notes, and snippets.

@9to6
Created September 24, 2019 03:37
Show Gist options
  • Save 9to6/5afa40c0029d51022ad14a17318e011c to your computer and use it in GitHub Desktop.
Save 9to6/5afa40c0029d51022ad14a17318e011c to your computer and use it in GitHub Desktop.
Bash script to restore jenkins jobs
#!/bin/bash
JENKINS_URL=$1
PWD=$(pwd)
ls ./jobs/ |
while read line
do
filepath="'$PWD/jobs/$line'"
filename="${line%%.*}"
echo "$filepath"
echo "$filename"
echo "cat $filepath | java -jar jenkins-cli.jar -s $JENKINS_URL create-job '$filename'"
bash -c "cat $filepath | java -jar jenkins-cli.jar -s $JENKINS_URL create-job '$filename'" &
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment