Trigger Jenkins Job Remotely using Jenkins API

  1. Configure a job to trigger from remote
  2. Trigger the job from a remote resource
Configure options for Authentication Token
  • Add the token name and click on the “Generate”
  • Copy the token name (We will configure this token in the job)
Add new token
// Run when the anonymous user has the build permission
$curl http://127.0.0.1:8080/job/Trigger_Remote_Demo/build?token=My-token
//Send request with credentials
$curl -u username:api_token http://127.0.0.1:8080/job/Trigger_Remote_Demo/build?token=My-token
// Build with Parameter
$curl -u username:api_token http://127.0.0.1:8080/job/Trigger_Remote_Demo/buildWithParameters?token=My-token&para1=val1&para2=val2
$wget http://127.0.0.1:8080/job/Trigger_Remote_Demo/build?token=My-token$wget --auth-no-challenge --http-user=username --http-password=api_token http://127.0.0.1:8080/job/Trigger_Remote_Demo/build?token=My-token
  1. Add the crumb in the request header
curl -H "Jenkins-Crumb:670fd068556684829074ac2e1c62ae782899456d64de907********" -u admin:11de80ecdf6e9948**************** http://127.0.0.1:8080/job/Trigger_Remote_Demo/build?token=My-token

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store