Skip to content

Instantly share code, notes, and snippets.

@jaimevalero
Last active March 30, 2021 10:31
Show Gist options
  • Save jaimevalero/c5b28bccfee1dbff135b8c9253fb5dd9 to your computer and use it in GitHub Desktop.
Save jaimevalero/c5b28bccfee1dbff135b8c9253fb5dd9 to your computer and use it in GitHub Desktop.
Execute jenkins jobs using curl and crumb
# Execute a job in jenkins, using api and crumb
# Replace CRED for your credentials and my_jenkins_instance.com with your jenkins instance
CRED=<admin:secret>
# Get crumb
CRUMB=`curl -s --cookie-jar ./cookie -k -u "$CRED" 'https://my_jenkins_instance.com/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)' `
# Execute a job without parameters
curl -k -sS --cookie ./cookie -H $CRUMB 'https://my_jenkins_instance.com/job/test/build' -X POST --user $CRED
# Execute a job with parameters
curl -k -sS --cookie ./cookie -H $CRUMB 'https://my_jenkins_instance.com/job/test2/buildWithParameters' -X POST --data "key=value" --user $CRED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment