Help Center/ CodeArts Build/ API Reference/ Application Examples/ Example 2: Querying Build Tasks by Project ID
Updated on 2023-12-08 GMT+08:00

Example 2: Querying Build Tasks by Project ID

Scenario

This section describes how to use an API to query build tasks by project ID.

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

Constraints

The project already exists and build tasks have already been created in CodeArts Build.

Involved APIs

API for querying build tasks by user token and project ID.

Procedure

  1. Query the build tasks in a specified project.

    • API information

      URI: GET /v3/{project_id}/jobs

      For details about the API, see Viewing the build task List of Users in a Project.

    • Example request
      GET  https://cloudbuild-ext.ap-southeast-3.myhuaweicloud.com/v3/8391ec48637849f384dd3db5c8d61.../jobs?page_index=0&page_size=2
    • Example response
      {
          "total": 35,
          "jobs": [{
              "id": "d62d64d7782545c696ffaacc9ac9c69a",
              "job_name": "Build-Create_Images_and_Push_to_SWR",
              "job_creator": "b7066bfb50194e36b472a61f088bbf72",
              "user_name": "L0_codeci",
              "last_build_time": 1598438571000,
              "health_score": 100,
              "source_code": "codeci",
              "last_build_status": "blue",
              "is_finished": true,
              "disabled": false,
              "favorite": true,
              "is_modify": true,
              "is_delete": true,
              "is_execute": true,
              "is_copy": true,
              "is_forbidden": true,
              "is_view": true
          },
          {
              "id": "4485de11a8e74ffdb9c9f85bafb85f83",
              "job_name": "Build-Use_SWR_Public_Images",
              "job_creator": "b7066bfb50194e36b472a61f088bbf72",
              "user_name": "L0_codeci",
              "last_build_time": 1598438567000,
              "health_score": 100,
              "source_code": "codeci",
              "last_build_status": "blue",
              "is_finished": true,
              "disabled": false,
              "favorite": true,
              "is_modify": true,
              "is_delete": true,
              "is_execute": true,
              "is_copy": true,
              "is_forbidden": true,
              "is_view": true
          }]
      }