9

I have tried to execute(trigger) jenkins job (not a parameterized job) via curl command by using below methods but it showing these results. my jenkins version is Jenkins 2.73.3

curl -X POST -u jenkins_user_name:jenkins_user_passwd http://jenkins_server/job/job_name/build

But it says Forbidden 403 enter image description here

Therefore, I have created a Authentication Token for the Job enter image description here

curl -X POST http://jenkins_server/job/job_name/build?token=wefiytgwiefiweihfqweiodf

It's also giving the same error. it says Forbidden 403

After that , I have created an API Token for jenkins User and tried. enter image description here

curl -X POST -u auto:testingdae6dc22a73048e6d596e7b0 http://jenkins_server/job/job_name/build?token=wefiytgwiefiweihfqweiodf

But It also the same , it says Forbidden 403

Actually I have followed this answer as well. https://www.nczonline.net/blog/2015/10/triggering-jenkins-builds-by-url/ this is also not worked for me.

every time , It's 403 forbidden. I think I couldn't authenticate jenkins user properly.

9

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
| improve this answer | |
  • 1
    Just tried this... I added an Auth-token and used it with curl -u auto:<jenkins_user_token> http://<jenkins_server>/job/test/build?token=wefiytgwiefiweihfqweiodf and got <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <title>Error 403 No valid crumb was included in the request</title> </head> <body><h2>HTTP ERROR 403</h2> <p>Problem accessing /job/hailo_ci_pull_request/build. Reason: <pre> No valid crumb was included in the request</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/> </body> </html> – CIsForCookies Feb 4 '19 at 13:58
  • seems like you have entered the wrong authentication token. please check this part "token=wefiytgwiefiweihfqweiodf" with your authentication token. – Prabath Dolawatta Feb 4 '19 at 14:31
  • I used my authentication token that I generated from the API token in my user tab - http://<IP>/user/<my_name>/configure – CIsForCookies Feb 4 '19 at 15:26
2

To configure these permissions:

  • Click Manage Jenkins
  • Click Configure Global Security
  • Remove Prevent Cross Site Request Forgery exploits
  • Click save
| improve this answer | |
  • 2
    Sounds like this would undermine the security of your system. Do you really want every website you visit to be able to run jobs on your Jenkins install? – kasperd Oct 25 '18 at 18:40
  • You should use tokens instead of doing that. Security first !!!! – Robert Jun 25 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.