Running a Build Task Upon Code Commit
Function
When the code is updated, the system automatically triggers the build task, enabling an automated process from code commit to build execution.
Calling Method
For details, see Calling APIs.
URI
POST /v1/job/{job_id}/auto-execute
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
job_id |
Yes |
String |
Definition Enter the ID of the build task whose history you want to query. To obtain this ID, open the build task details page in your browser, and copy the 32-character string, which includes both digits and letters, at the end of the URL. Constraints N/A. Range The value is 32 characters long. Only letters and digits are allowed. Default Value N/A. |
Request 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 can be obtained by calling the IAM service API. For details, seeObtaining an IAM User Token. Constraints Global tenant tokens are not supported. Use a region-level token whose scope is project. Range N/A. Default Value N/A. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
event_type |
No |
String |
Definition Event type. Constraints push or push_events Range N/A. Default Value N/A. |
|
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. |
|
ref |
No |
String |
Definition Name of the code repository branch. Constraints N/A. Range N/A. Default Value N/A. |
|
after |
No |
String |
Definition ID of the commit that triggers the build process. The commit ID can be retrieved from the commit message in the code repository. Constraints N/A. Range N/A. Default Value N/A. |
|
before |
No |
String |
Definition ID of the commit that triggers the build process. The commit ID can be retrieved from the commit message in the code repository. Constraints N/A. Range N/A. Default Value N/A. |
|
commits |
No |
Array of CommitsItem objects |
Definition Custom parameters. Constraints N/A. Range N/A. Default Value N/A. |
|
repository |
No |
Repository object |
Definition Code information. Constraints N/A. Range N/A. Default Value N/A. |
Response Parameters
Status code: 200
|
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. |
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}/v1/job/execute
{
"event_type" : "push",
"commits" : [ {
"id" : "2fdc0170f0d540ae952c03ee6cabae3a8943d16a",
"message" : "Update README.md"
} ],
"ref" : "refs/heads/master",
"repository" : {
"url" : "git@codehub.devcloud.cn-north-7.ulanqab.huawei.com:0618c0132d524af6b81030b083d00687/Python2.git",
"name" : "Python2"
},
"after" : "2fdc0170f0d540ae952c03ee6cabae3a8943d16a",
"before" : "5c749465b14af7368b09945ed56942d54bc0b40d"
}
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 |
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