see jenkins Of api

Direct access JENKINS_URL/job/JOB_NAME/api/ You can view it jenkins Of api

build One job The words of , yes POST request  JENKINS_URL/job/JOB_NAME/build

Will prompt :

This is jenkins Caused by the security policy of , Need to pass a crumb



There are two options ,

The first option :

1. Remove it first jenkins Security policy settings for , As shown in the figure , Remove the tick

stay jenkins Global security settings Uncheck “ Prevent cross Site Request Forgery (Prevent Cross Site Request Forgery exploits)”

2. allow anonymous visit , As shown in the figure below , Check on

3. set up token,token Is for the specified job Of , So go there job Middle to set

Then you can go through the POST Request access  JENKINS_URL/job/test1/build?token=TOKEN_NAME Trigger this job 了



The second option : Security does not need to be removed to prevent cross site request forgery , By passing on crumb To achieve ; But allowed anonymous Access should be set

 POST Bring this with you when you ask Jenkins-Crumb( This method is recommended )

  visit JENKINS_URL/crumbIssuer/api/json You can get your crumb, Of course, different clients get different access



The JENKINS_URL Replace it with your own jenkins address ,

JOB_NAME replace with job The name of ;

TOKEN_NAME Replace it with your own token value , Like the one above me jwentest1