Help Center/ CodeArts Build/ API Reference/ Application Examples/ Example 1: Executing a Build Task and Checking Its Status
Updated on 2023-12-08 GMT+08:00

Example 1: Executing a Build Task and Checking Its Status

Scenario

This section describes how to use APIs to execute a build task and check whether the task is running.

For details about how to call APIs, see Calling APIs.

Constraints

The build task to execute has already been created in CodeArts Build.

Involved APIs

Execute the build task using a user token and task ID, and then check the task status based on the task ID. The procedure is as follows:

  1. Executing a build task.
  2. Querying task running status.

Procedure

  1. Execute a build task.

    • API information

      URI: POST /v3/jobs/build

      For details about the API, see Execute the Build Task.

    • Example request
      POST  https://cloudbuild-ext.ap-southeast-3.myhuaweicloud.com/v3/jobs/build
    • Example request body
      {
          "job_id": "3341eaf0de6844669f07baa1ddfc9..."
      }
    • Example response
      {
          "octopus_job_name": "j_WfRE6eOY",
          "actual_build_number": "55",
          "daily_build_number": "20200825.1"
      }

  2. Check whether the task is running.

    • API information

      URI: GET /v3/jobs/{job_id}/status

      For details about the API, see Viewing the Running Status of a Task.

    • Example request
      GET  https://cloudbuild-ext.ap-southeast-3.myhuaweicloud.com/v3/jobs/3341eaf0de6844669f07bdfc9.../status
    • Example response
      {
          "result": false
      }