How I Triggered a Jenkins Job via CURL command


A Step-by-Step Guide to Triggering Jenkins Jobs with CURL Commands on Windows
Install Jenkins on Windows
- Ensure Jenkins is installed and configured on your Windows machine.
Download CURL Executable File
By default, Windows comes with CURL. If it's not available, download CURL from the official CURL website
Link : Download
Unzip the downloaded file and add the path to your system’s Environment Variables.
Create Jenkins Token
A Jenkins Token (often referred to as a Jenkins API Token or Jenkins Authentication Token) is a secure, temporary key used to authenticate API requests to Jenkins from external systems, such as scripts, CI/CD tools, or automation processes.
How to Generate a Jenkins API Token
Log in to your Jenkins instance.
Navigate to Manage Jenkins > Manage Users.
Select your user profile.
Under the Security section, click API Token.
Click Generate new token.
Copy the generated token – this will be used in your API requests / Curl command to run.
Click on your profile
Click on Security > Add Token, give it a name, and generate it
Copy the generated token and store it securely, as it will be needed when running the CURL command.
Create a Sample Jenkin Job
We will create a sample job to test. For this test, we will use a Pipeline job, but you can use any job type. You’ll only need the Jenkins job name, which will be used in the CURL command to trigger the job.
Note your job_name : my_jenkin_curl_trigger
Add sample script - using auto script of hello world for my test and saving it
Note this Job url : http://localhost:8080/job/my_jenkin_curl_trigger/ ( Will be used in curl command )
Run Jenkin Job via CURL command on cmd
Run the following command in your terminal or Command Prompt
Sample command ( Replace url , username , token to run your jenkin job )
curl -X POST "http://<JENKINS_URL>/job/<JOB_NAME>/build" --user <USERNAME>:<API_TOKEN>
My details added to run Jenkin job
curl -X POST "http://localhost:8080/job/my_jenkin_curl_trigger/build" --user coding:112a6a6a9fc12459ea230a34d0ed30d69d
The above command runned on cmd as invoked my Jenkin Job
Following is the Console Output of above job
Check status of Jenkin Job via CURL command on cmd
You can monitor the build status in Jenkins via the web interface or use another cURL command to check the job status
curl "http://<JENKINS_URL>/job/<JOB_NAME>/lastBuild/api/json" --user <USERNAME>:<API_TOKEN>
Added my details to run command
curl "http://localhost:8080/job/my_jenkin_curl_trigger/lastBuild/api/json" --user coding:112a6a6a9fc12459ea230a34d0ed30d69d
You can see the status : SUCCESS or FAILURE of Jenkin job
If you found my post helpful, feel free to show your support by buying me a coffee! ☕
Subscribe to my newsletter
Read articles from vikas bhaskar vooradi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

vikas bhaskar vooradi
vikas bhaskar vooradi
In my free time, I enjoy coding, blogging, and exploring technology-related content on the internet.