How to build a job using the REST API and cURL?

Article ID:218889337
1 minute readKnowledge base

Issue

I would like to be able to build a job remotely using the Jenkins REST API and cURL. This also provides a workaround for JENKINS-12543, that doesn’t require SSH Key Authentication.

Resolution

Example build:

curl --user USER:API_TOKEN -X POST https://localhost:8080/job/test/build

Replace:

  • USER:API_TOKEN with your username and API token

  • localhost:8080 with your Jenkins URL

  • test with your job name

Example build with String parameter:

curl --user USER:API_TOKEN -X POST https://localhost:8080/job/test/build --data-urlencode json='{"parameter": [{"name":"paramA", "value":"123"}]}'

Replace:

  • USER:API_TOKEN with your username and API token

  • localhost:8080 with your Jenkins URL

  • test with your job name

  • paramA with your parameter name

  • 123 with your parameter value

See Remote Access API for more.