Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-21065

DELETE on queue REST API to stop an in-progress build does not work as specified

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • 5.15.5, 7.1.1
    • API
    • None

    Description

      Issue Summary

      DELETE on queue REST API to stop an in-progress build does work as specified (the API reference states that it stops build execution). Instead, the behaviour is as follows:

      • The job remains in progress after the first delete call if its only job in the stage
      • If there are multiple jobs in the stage, it looks to be cancelled but looking at the job result will cause a refresh spam
      • The command the agent is running continues.

      A second delete call will change the job status to cancelled, however the agent will still be running the command.

      Steps to Reproduce

      1. Create a single stage plan with two jobs
      2. Add a script task:
        sleep 120;
        
      3. Perform a build
      4. Issue a DELETE to the API:
        BAMBOO_USERNAME=
        BAMBOO_BASE_URL=
        BAMBOO_JOB_BUILD_KEY=
        curl -vvv --user $BAMBOO_USERNAME -X DELETE $BAMBOO_BASE_URL/rest/api/latest/queue/$BAMBOO_JOB_BUILD_KEY
        
      5. Viewing the job result in the UI will create a browser refresh loop
      6. The job is still running on the agent
      7. Issue a second DELETE to the API:
        BAMBOO_USERNAME=
        BAMBOO_BASE_URL=
        BAMBOO_JOB_BUILD_KEY=
        curl -vvv --user $BAMBOO_USERNAME -X DELETE $BAMBOO_BASE_URL/rest/api/latest/queue/$BAMBOO_JOB_BUILD_KEY
        
      8. The refresh loop is broken now and the job result is cancelled but the actual job is still in progress on the agent.

      Expected Results

      The job execution is stopped and the result is cancelled, in the same fashion as if you had hit Stop Job in the UI.

      Actual Results

      Refresh loops when viewing the job and despite the job eventually being cancelled, its still running and consuming an agent.

      Workaround

      Once in this state, you need to wait for the job to complete. In future, you can stop the job from the UI (Build result > Select Job > Actions > Stop Job) instead of the REST API.

      If an automated stop is required, you can use the same Struts action Bamboo uses from the UI, however it should be avoided unless necessary since its usage may change in future versions without warning:

      BAMBOO_BASE_URL=https://localhost:8085
      BAMBOO_JOB_BUILD_KEY=PROJ-PLAN-JOB1-1
      BAMBOO_USERNAME=bamboo
      curl --user $BAMBOO_USERNAME -X POST "$BAMBOO_BASE_URL/build/admin/stopPlan.action?planResultKey=$BAMBOO_JOB_BUILD_KEY" \
        -H 'Content-Type: application/x-www-form-urlencoded' \
        -H 'X-Atlassian-Token: no-check'
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jowen@atlassian.com Jeremy Owen
              Votes:
              12 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

                Created:
                Updated: