Skip to content

Instantly share code, notes, and snippets.

@wheelq
Created April 16, 2019 08:35
Show Gist options
  • Save wheelq/4a477926d7fcaf6040909f91d10ce5a2 to your computer and use it in GitHub Desktop.
Save wheelq/4a477926d7fcaf6040909f91d10ce5a2 to your computer and use it in GitHub Desktop.
Export Jenkins jobs
#######Export######
java -jar jenkins-cli.jar -s http://server get-job myjob > myjob.xml
curl -s http://OLD_JENKINS/job/JOBNAME/config.xml
#Local export
/var/lib/jenkins/jobs/-the-project-name-/config.xml
###################
####export/import####
curl -s http://OLD_JENKINS/job/JOBNAME/config.xml | curl -X POST 'http://NEW_JENKINS/createItem?name=JOBNAME' --header "Content-Type: application/xml" -d @-
#with authentication:
curl -s http:///<USER>:<API_TOKEN>@OLD_JENKINS/job/JOBNAME/config.xml | curl -X POST 'http:///<USER>:<API_TOKEN>@NEW_JENKINS/createItem?name=JOBNAME' --header "Content-Type: application/xml" -d @
#####################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment