How to stop a build in Jenkins via the REST api ?

前端 未结 4 1052
我寻月下人不归
我寻月下人不归 2020-12-01 08:08

I have a job in Jenkins. A website of our own triggers builds of this job via the REST api. Sometimes we want to abort the build. Sometimes, it can be before the build is ev

4条回答
  •  失恋的感觉
    2020-12-01 08:56

    Maybe you want to remotely send a post http request to stop a running build, there is a clue FYI, the jenkins job can stop another job(running build), like any jenkins admin click the X button when job is running.

    1. Http Request Plugins is required by Jenkins ver2.17
    2. Uncheck the Prevent Cross Site Request Forgery exploits option. Manager Jenkins -> Configure Global Security -> Uncheck
    3. Setup Http Request Plugins's authorization. Manager Jenkins -> Configure System -> HTTP Request Basic/Digest Authentication -> add. Make sure the user has the job cancel permission
    4. Job A is running. In job B, add build step as HTTP Request, URL: http://Jenkins_URL/job/Job_A_Name/lastBuild/stop, HTTP mode: POST, Authorization select the user you have just set, then build job B.

    Done

提交回复
热议问题