how to trigger jenkins job via curl command remotely

found the answer. Actually those steps are correct. I would like to mention the correct steps.

Create a user in Jenkins, you can use that user password or API token for trigger Jenkins job. But creating an API token for that user is much better. But both ways working fine.

But you have to create an Authentication token for Jenkins Job

enter image description here

Using Password

curl -I -u auto:<userpasswd> http://<jenkins_server>/job/test/build?token=wefiytgwiefiweihfqweiodf

Using an API Token

Create an API token for that Jenkins user enter image description here

curl -I -u auto:<user_api_token> http://<jenkins_Server>/job/test/build?token=wefiytgwiefiweihfqweiodf

these are the results, using jenkins user Password and jenkins user API token.

enter image description here

Actually you can send this request , without "-I" as well.

curl -u auto:<jenkins_user_token> http://<jenkins_server>/job/test/build?token=wefiytgwiefiweihfqweiodf

curl -u auto:<jenkins_user_password> http://<jenkins_server>/job/test/build?token=wefiytgwiefiweihfqweiodf

Tags:

Curl

Jenkins