Updated on 2025-09-22 GMT+08:00

Running a Build Task

Function

This API is used to run a build task and allows custom parameters.

Calling Method

For details, see Calling APIs.

URI

POST /v3/jobs/build

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token. (The value of the X-Subject-Token response header is the user token.) It is obtained by calling the IAM API.

Constraints

Global tenant tokens are not supported. Use a region-level token whose scope is project.

Range

N/A.

Default Value

N/A.

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

job_id

Yes

String

Definition

Build task ID. It includes digits and letters. To obtain this ID, open the page for editing the build task in your browser, and copy the 32-character string at the end of the URL.

Constraints

The 32-character string sits at the end of the URL and includes digits and letters.

Range

N/A.

Default Value

N/A.

parameter

No

Array of ParameterItem objects

Definition

Custom parameter.

Constraints

N/A.

Range

N/A.

Default Value

N/A.

scm

No

Scm object

Definition

Code information.

Constraints

N/A.

Range

N/A.

Default Value

N/A.

Table 3 ParameterItem

Parameter

Mandatory

Type

Description

name

Yes

String

Definition

Custom parameter name.

Constraints

● Do not use the following fields: LD_PRELOAD, LD_LIBRARY_PATH, PATH, BASH_ENV, GIT_SSH_COMMAND, and path.

● Symbols are not supported.

Range

Custom parameter name. The length cannot exceed 128 characters. Only letters, digits, and underscores (_) are supported.

Default Value

N/A.

value

Yes

String

Definition

Parameter value.

Constraints

N/A.

Range

Default value of the custom parameter. Max. 8,192 characters.

Default Value

N/A.

Table 4 Scm

Parameter

Mandatory

Type

Description

build_tag

No

String

Definition

Code tag.

Constraints

N/A.

Range

N/A.

Default Value

N/A.

build_commit_id

No

String

Definition

Code commit ID.

Constraints

N/A.

Range

N/A.

Default Value

N/A.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

octopus_job_name

String

Definition

Temporary task name.

Range

N/A.

actual_build_number

String

Definition

Number of actual builds.

Range

N/A.

daily_build_number

String

Definition

Daily build number.

Range

N/A.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 404

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

Run the build task whose task ID is f9d6c8466d614a9788e9a0acf6c15f46. The task uses the codeBranch code repository and the master branch.

POST https://{endpoint}/v3/jobs/build

{
  "job_id" : "f9d6c8466d614a9788e9a0acf6c15f46",
  "parameter" : [ {
    "name" : "codeBranch",
    "value" : "master"
  } ],
  "scm" : {
    "build_tag" : null,
    "build_commit_id" : "build_commit_id"
  }
}

Example Responses

Status code: 200

OK

{
  "octopus_job_name" : "j_Oaqg...",
  "actual_build_number" : "20",
  "daily_build_number" : "20200612.20"
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.