Last active
March 30, 2021 10:31
-
-
Save jaimevalero/c5b28bccfee1dbff135b8c9253fb5dd9 to your computer and use it in GitHub Desktop.
Execute jenkins jobs using curl and crumb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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