Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arellano-gustavo/735060e6787153d0fac0c70bd04ce1c5 to your computer and use it in GitHub Desktop.
Save arellano-gustavo/735060e6787153d0fac0c70bd04ce1c5 to your computer and use it in GitHub Desktop.
How to get a Jenkins Job as a local XML file. Then, create a new job.
# Please consider the $1 variable in here: (it is the job name)
curl -k -s \
https://jenkins.url.site/job/$1/config.xml \
-u jenkins-user:111f65b8xxxxxc395df \
-o $1-config.xml
# Now, we will use 2 variables: $1 & $2: (new job name & file with its definition)
CRUMB=$(\
curl -k \
'https://jenkins.url.site/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)' \
-u jenkins-user:11e2c481zzzzzz0e82f445)
curl -k -X POST \
https://jenkins.ci.ultrasist.net/createItem?name=$1 \
-u jenkins-user:11e2481ww0e8d22fda0445 \
--data-binary @$2 \
-H "$CRUMB" \
-H "Content-Type:text/xml"
# Note: the value for jenkins-user should be obtained previously, from the "jenkins-user" account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment