Creating a Check Task (Version 3)
Function
This API is used to create a code check task in a project based on the project ID, repository address, branch, task name, and rule set, and returns the ID of the new code check task.
Calling Method
For details, see Calling APIs.
Authorization Information
Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.
|
Action |
Access Level |
Resource Type (*: required) |
Condition Key |
Alias |
Dependencies |
|---|---|---|---|---|---|
|
codeartscheck:task:create |
Write |
task * |
- |
- |
- |
|
- |
codeartscheck:ProjectId |
URI
POST /v3/task
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
branch |
Yes |
String |
Definition: Repository branch. Constraints: N/A Value range: 1 to 200 characters. Default value: N/A |
|
config_template |
Yes |
CreateTaskV3ConfigTemplate object |
Definition: Task configuration template parameter, which stores configurations related to the task. Constraints: N/A Value range: N/A Default value: N/A |
|
name |
Yes |
String |
Definition: Task name. Constraints: 1 to 128 characters. The value can contain any letters, digits, periods (.), hyphens (-), and underscores (_). Value range: 1 to 128 characters. Default value: N/A |
|
project_id |
No |
String |
Definition : 32-character project UUID. Obtain it by calling the API used to query the project list. Constraints: N/A Value range: 32-character project ID. Default value: N/A |
|
project_name |
No |
String |
Definition : Project name. Obtain the name by calling the API used to query the project list. Constraints: N/A Value range: N/A Default value: N/A |
|
repo_url |
Yes |
String |
Definition: Code repository address. Constraints: N/A Value range: For a CodeArts Repo repository, enter an address starting with git. For a non-CodeArts Repo repository, enter an address starting with http. Default value: N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
repo_type |
Yes |
String |
Definition: Code repository type. Constraints: N/A Value range: Default value: N/A |
|
branch |
Yes |
String |
Definition: Branch name. Constraints: N/A Range: N/A Default value: N/A |
|
rule_sets |
Yes |
Array of ConfigTemplateRuleSet objects |
Definition: Rule set list. |
|
project_id |
Yes |
String |
Definition : 32-character project UUID. Obtain it by calling the API used to query the project list. Constraints: N/A Value range: 32-character project ID. Default value: N/A |
|
project_name |
Yes |
String |
Definition : Project name. Obtain the name by calling the API used to query the project list. Constraints: N/A Value range: N/A Default value: N/A |
|
authId |
No |
String |
Definition: The ID of an existing code source endpoint for storing repository information in a project. Constraints: This parameter is mandatory for repositories other than CodeArts Repo. Range: N/A Default value: N/A |
|
authType |
No |
String |
Definition: Authorization type. Constraints: This parameter is mandatory for repositories other than CodeArts Repo. Value range: Default value: N/A |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
result |
CreateTaskV3Result object |
Definition: Result of creating a check task. |
|
httpStatus |
String |
Definition: HTTP response status. Value range: |
|
status |
String |
Definition: API response status. Value range: |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Definition : Task ID, returned by the API for creating a check task. Each code check task, branch task, or incremental task generated through an API has a unique ID. Obtain the ID by calling the API used to . id indicates the task ID. Constraints: N/A Value range: 1 to 32 characters. Default value: N/A |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Definition: Error code. Value range: N/A |
|
error_msg |
String |
Definition: Error message. Value range: N/A |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Definition: Error code. Value range: N/A |
|
error_msg |
String |
Definition: Error message. Value range: N/A |
Example Requests
Create a code check task named CppWebHookTest, with the branch being master, the check language being C++, and the repository type being CodeArts Repo in the project whose project ID is 8c7c74775f4f496596e4a39d34b209c3 and project name is projectName.
POST https://{endpoint}/v3/task
{
"repo_url" : "git@codehub.devcloud.example.com:8c7c74775f4f496596e4a39d34b209c3/CppWebHookTest.git",
"branch" : "master",
"name" : "CppWebHookTest",
"config_template" : {
"branch" : "master",
"repo_type" : "DevCloud",
"rule_sets" : [ {
"language" : "C++"
} ],
"project_id" : "8c7c74775f4f496596e4a39d34b209c3",
"project_name" : "projectName"
},
"project_id" : "8c7c74775f4f496596e4a39d34b209c3",
"project_name" : "projectName"
}
Example Responses
Status code: 200
Request succeeded!
{
"httpStatus" : "OK",
"result" : {
"checkParamList" : [ ],
"criterionSets" : [ ],
"customParams" : [ ],
"id" : "8df8d58f832a408f88e4aebea0ff6fc5",
"modelSets" : [ ],
"reviewData" : [ ],
"ruleSets" : [ ],
"taskIds" : [ ],
"versionUpdateDelayDays" : [ ]
},
"status" : "success"
}
Status code: 400
Bad Request
{
"error_code" : "CC.xxxxxxxx.400",
"error_msg" : "Verify request parameter failed. Check whether the request parameters are correct."
}
Status code: 401
Unauthorized
{
"error_code" : "CC.00000003",
"error_msg" : "Authentication information expired."
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Request succeeded! |
|
400 |
Bad Request |
|
401 |
Unauthorized |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot