Skip to content

Instantly share code, notes, and snippets.

@dasgoll
Created January 28, 2017 15:42
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save dasgoll/455522f09cb963872f64e23bb58804b2 to your computer and use it in GitHub Desktop.
Save dasgoll/455522f09cb963872f64e23bb58804b2 to your computer and use it in GitHub Desktop.
Jenkins REST API example using crumb
Each Jenkins page has a REST API hyperlink at the bottom, this is because each page has its own endpoint.
http://localhost:8080/me
configure
Click 'Show API Token'
78e21f82a9e137614fef5b9593bcf827 = API Token
curl -s -u goll:78e21f82a9e137614fef5b9593bcf827 http://localhost:8080/crumbIssuer/api/json
curl -s -u goll:78e21f82a9e137614fef5b9593bcf827 -H 'Jenkins-Crumb:0f23a062e0b9b9d13295e26bc8c8e206' http://localhost:8080/job/foo2/buildWithParameters -d 'directoryName=zaid222'
@gragonmau
Copy link

Thank you :D worked like a charm

@Puneeth-n
Copy link

🙏

@aluc267
Copy link

aluc267 commented May 17, 2018

👍

@jasonmci
Copy link

💯

@karan-wahie03
Copy link

I am only able to start my own jobs not those which were created by some other users even though I am an admin user. It says invalid crum error 403. Any idea why?

@Wadeck
Copy link

Wadeck commented Jul 11, 2019

FYI since 2.96 (https://jenkins.io/changelog/#v2.96), the CSRF token (crumb) is no longer required if you are using an API Token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment