Updated on 2024-04-18 GMT+08:00

Creating a Build Task

Function

This API is used to create a build task.

Calling Method

For details, see Calling APIs.

URI

POST /v3/jobs/create

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API. (Value of X-Subject-Token in the response header.) Global tenant tokens are not supported. Use a region-level token whose scope is project.

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

arch

Yes

String

Architecture.

project_id

Yes

String

ID of the project to which the build task belongs.

job_name

Yes

String

Task name.

auto_update_sub_module

No

String

Whether to automatically update submodules.

flavor

No

String

Executor flavors.

parameters

No

Array of CreateBuildJobParameter objects

Parameters for build execution.

scms

No

Array of CreateBuildJobScm objects

SCMs of build execution.

steps

Yes

Array of CreateBuildJobSteps objects

Build actions.

host_type

No

String

Host type.

build_config_type

No

String

Build configuration type.

Table 3 CreateBuildJobParameter

Parameter

Mandatory

Type

Description

name

No

String

Parameter definition name. The default value is hudson.model.StringParameterDefinition.

params

No

Array of CreateBuildJobParameterParam objects

Subparameters of build execution parameters.

Table 4 CreateBuildJobParameterParam

Parameter

Mandatory

Type

Description

name

No

String

Parameter field name.

value

No

String

Parameter field value.

limits

No

Array of LimitsParam objects

Restrictions on enumeration parameters.

Table 5 LimitsParam

Parameter

Mandatory

Type

Description

disable

No

String

Whether the configuration takes effect. The default value is 0, indicating that the configuration takes effect.

display_name

No

String

Parameter display name.

name

No

String

Parameter name.

Table 6 CreateBuildJobScm

Parameter

Mandatory

Type

Description

branch

No

String

Branch.

url

Yes

String

Code repository address.

repo_id

No

String

Repo ID.

web_url

No

String

HTTP address of the code repository.

scm_type

Yes

String

Repository type, such as Repo and GitHub.

is_auto_build

No

Boolean

Whether to enable auto build.

build_type

No

String

Build type.

depth

No

String

Clone depth.

end_point_id

No

String

endpointId

source

No

String

source

Table 7 CreateBuildJobSteps

Parameter

Mandatory

Type

Description

properties

No

Map<String,Object>

Build action.

module_id

Yes

String

Build module ID.

name

Yes

String

Build module name.

version

No

String

Build version.

enable

No

Boolean

Enable or not.

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

result

result object

Result.

status

String

Status information.

error

String

Error message.

Table 9 result

Parameter

Type

Description

job_id

String

Build task ID.

Status code: 400

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 401

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 403

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 404

Table 13 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 500

Table 14 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Example Requests

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

{
  "arch" : "x86-64",
  "project_id" : "a287e712be6c404ca26e5f69040fa12b",
  "job_name" : "examplejob",
  "auto_update_sub_module" : "false",
  "flavor" : "2u8g",
  "parameters" : [ {
    "name" : "hudson.model.StringParameterDefinition",
    "params" : [ {
      "name" : "name",
      "value" : "codeBranch"
    }, {
      "name" : "type",
      "value" : "normalparam"
    }, {
      "name" : "defaultValue",
      "value" : "master"
    }, {
      "name" : "description",
      "value" : "description"
    }, {
      "name" : "deletion",
      "value" : "false"
    }, {
      "name" : "defaults",
      "value" : "true"
    }, {
      "name" : "staticVar",
      "value" : "false"
    }, {
      "name" : "sensitiveVar",
      "value" : "false"
    } ]
  } ],
  "scms" : [ {
    "branch" : "master",
    "url" : "git@codehub.devcloud.cn-north-7.ulanqab.huawei.com:soso-test00001/an.git",
    "repo_id" : "2111746211",
    "web_url" : "https://codehub.devcloud.cn-north-7.ulanqab.huawei.com/codehub/2111746211/home",
    "scm_type" : "codehub",
    "is_auto_build" : false,
    "build_type" : "branch",
    "depth" : "1"
  } ],
  "steps" : [ {
    "properties" : null,
    "module_id" : "devcloud2018.codeci_action_20043.action",
    "name" : "Build with Maven",
    "version" : "20231001.6",
    "enable" : true
  } ],
  "host_type" : "devcloud"
}

Example Responses

Status code: 200

OK

{
  "result" : {
    "job_id" : "db8467d972cc47f7a1bd2a3a3e77596a"
  },
  "error" : null,
  "status" : "success"
}

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.