Halaman ini belum tersedia dalam bahasa lokal Anda. Kami berusaha keras untuk menambahkan lebih banyak versi bahasa. Terima kasih atas dukungan Anda.
Querying Pipeline Logs
Function
This API is used to query pipeline logs.
Calling Method
For details, see Calling APIs.
URI
POST /v5/{project_id}/api/pipelines/{pipeline_id}/pipeline-runs/{pipeline_run_id}/jobs/{job_run_id}/steps/{step_run_id}/logs
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Parameter description: CodeArts project ID. Constraints: N/A. Value Range: The value contains 32 characters. Default value: N/A. |
pipeline_id |
Yes |
String |
Parameter description: Pipeline ID. Constraints: N/A. Value Range: The value contains 32 characters. Default value: N/A. |
pipeline_run_id |
Yes |
String |
Parameter description: Pipeline run ID. Constraints: N/A. Value Range: The value contains 32 characters. Default value: N/A. |
job_run_id |
Yes |
String |
Parameter description: Pipeline job ID. Constraints: None. Value range: 32 characters, including only digits and letters. Default value: None. |
step_run_id |
Yes |
String |
Parameter description: Pipeline step ID. Constraints: None. Value range: 32 characters, including only digits and letters. Default value: None. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Parameter description: User token. It can be obtained by calling the IAM API. The value of X-Subject-Token in the response header is the user token. Constraints: None. Value range: None. Default value: None. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
start_offset |
No |
Long |
Parameter description: Log start offset. Constraints: None. Value range: None. Default value: None. |
end_offset |
No |
Long |
Parameter description: Log end offset. Constraints: None. Value range: None. Default value: None. |
limit |
Yes |
Long |
Parameter description: Maximum number of log lines. Constraints: None. Value range: None. Default value: None. |
sort |
Yes |
String |
Parameter description: Sorting rule. Constraints: None. Value range: asc: Ascending; desc: Descending. Default value: None. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
has_more |
Boolean |
Parameter description: Whether there are more logs. Value range: TRUE: more logs; FALSE: no more logs. |
end_offset |
String |
Parameter description: End offset of the log query. Enter the end_offset field in the request body to query logs on the next page. Value range: None. |
start_offset |
String |
Parameter description: Start offset of the queried logs. Enter the start_offset field in the request body to query logs on the next page. Value range: None. |
log |
String |
Parameter description: Log content. Value range: None. |
step_run_id |
String |
Parameter description: ID of the step to which it belongs. Value range: None. |
Example Requests
POST https://{endpoint}/v5/d80a8a6530324b7bac972cbb8a9f28ec/pipelines/e2bcbd561fbc4fd89577fb27c80b09a6/pipeline-runs/9e91b1fd7ce743b7a1b7a2458bcf76c7/jobs/6ce8600f396c4d5ba5290201ba9fd762/steps/7a1a7bb1b5e74d1c944d8b8971621033/logs
{
"start_offset" : 0,
"end_offset" : 0,
"limit" : 500,
"sort" : "asc"
}
Example Responses
Status code: 200
Response body for querying logs.
{
"has_more" : false,
"end_offset" : "25705",
"start_offset" : "6132",
"log" : "[2023/11/24 21:49:32.198 GMT+08:00] [INFO] [real_stage: Shell]: This step starts.\n[2023/11/24 21:49:32.201 GMT+08:00] [INFO] [real_stage: Shell]: ================== start to do VmExecutionStep ==================\n[2023/11/24 21:49:32.207 GMT+08:00] [INFO] [real_stage: Shell]: [frame] start to send status data to service.\n[2023/11/24 21:49:32.225 GMT+08:00] [INFO] [real_stage: Shell]: [frame] finish to save status data to service.\n[2023/11/24 21:49:32.777 GMT+08:00] [INFO] [real_stage: Shell]: slave arch: amd64\n[2023/11/24 21:49:33.330 GMT+08:00] [INFO] [real_stage: Shell]: download file result: SUCCESS\n[2023/11/24 21:49:36.547 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== flow agent launched in [octopus_container] ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== use env job loader ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] start to do status callback\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] successfully callback to flow service\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] step begin: [1/1]- [Execute Shell]\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] start to use official executor [official_shell_plugin]\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] ###############################@@@ [step start] @@@###############################\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== start to use script executor ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== start to execute shell pre function [make temp dir] ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== shell pre function [make temp dir] current temp dir:[/data/workspace/6ce8600f396c4d5ba5290201ba9fd762/7a1a7bb1b5e74d1c944d8b8971621033] ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== end to execute shell pre function [make temp dir] successfully ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== start to execute custom shell ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] 1\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== finish to use script executor with status success ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] ################################@@@ [step end] @@@################################\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] finish to use official executor\nThe [2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] step executes Shell succeed.\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] start to do data callback with context:[{1eaa92ecea2a42cab78e5269963a48c1 6ce8600f396c4d5ba5290201ba9fd762 7a1a7bb1b5e74d1c944d8b8971621033 0}]\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] successfully callback to flow service\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] current step, duration time: [0.030766842]\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] start to do status callback\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] successfully callback to flow service\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== flow agent end ===========\n[2023/11/24 21:49:36.563 GMT+08:00] [INFO] [real_stage: Shell]: [frame] start to send status data to service.\n[2023/11/24 21:49:36.563 GMT+08:00] [INFO] [real_stage: Shell]: This step is complete.",
"step_run_id" : "7a1a7bb1b5e74d1c944d8b8971621033"
}
SDK Sample Code
The SDK sample code is as follows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
package com.huaweicloud.sdk.test;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.codeartspipeline.v2.region.CodeArtsPipelineRegion;
import com.huaweicloud.sdk.codeartspipeline.v2.*;
import com.huaweicloud.sdk.codeartspipeline.v2.model.*;
public class ShowPipelineLogSolution {
public static void main(String[] args) {
// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
String ak = System.getenv("CLOUD_SDK_AK");
String sk = System.getenv("CLOUD_SDK_SK");
ICredential auth = new BasicCredentials()
.withAk(ak)
.withSk(sk);
CodeArtsPipelineClient client = CodeArtsPipelineClient.newBuilder()
.withCredential(auth)
.withRegion(CodeArtsPipelineRegion.valueOf("<YOUR REGION>"))
.build();
ShowPipelineLogRequest request = new ShowPipelineLogRequest();
request.withJobRunId("{job_run_id}");
request.withStepRunId("{step_run_id}");
request.withProjectId("{project_id}");
request.withPipelineId("{pipeline_id}");
request.withPipelineRunId("{pipeline_run_id}");
LogQuery body = new LogQuery();
body.withSort("asc");
body.withLimit(500L);
body.withEndOffset(0L);
body.withStartOffset(0L);
request.withBody(body);
try {
ShowPipelineLogResponse response = client.showPipelineLog(request);
System.out.println(response.toString());
} catch (ConnectionException e) {
e.printStackTrace();
} catch (RequestTimeoutException e) {
e.printStackTrace();
} catch (ServiceResponseException e) {
e.printStackTrace();
System.out.println(e.getHttpStatusCode());
System.out.println(e.getRequestId());
System.out.println(e.getErrorCode());
System.out.println(e.getErrorMsg());
}
}
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# coding: utf-8
import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcodeartspipeline.v2.region.codeartspipeline_region import CodeArtsPipelineRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcodeartspipeline.v2 import *
if __name__ == "__main__":
# The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
# In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
ak = os.environ["CLOUD_SDK_AK"]
sk = os.environ["CLOUD_SDK_SK"]
credentials = BasicCredentials(ak, sk)
client = CodeArtsPipelineClient.new_builder() \
.with_credentials(credentials) \
.with_region(CodeArtsPipelineRegion.value_of("<YOUR REGION>")) \
.build()
try:
request = ShowPipelineLogRequest()
request.job_run_id = "{job_run_id}"
request.step_run_id = "{step_run_id}"
request.project_id = "{project_id}"
request.pipeline_id = "{pipeline_id}"
request.pipeline_run_id = "{pipeline_run_id}"
request.body = LogQuery(
sort="asc",
limit=500,
end_offset=0,
start_offset=0
)
response = client.show_pipeline_log(request)
print(response)
except exceptions.ClientRequestException as e:
print(e.status_code)
print(e.request_id)
print(e.error_code)
print(e.error_msg)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
package main
import (
"fmt"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
codeartspipeline "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2/model"
region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2/region"
)
func main() {
// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
ak := os.Getenv("CLOUD_SDK_AK")
sk := os.Getenv("CLOUD_SDK_SK")
auth := basic.NewCredentialsBuilder().
WithAk(ak).
WithSk(sk).
Build()
client := codeartspipeline.NewCodeArtsPipelineClient(
codeartspipeline.CodeArtsPipelineClientBuilder().
WithRegion(region.ValueOf("<YOUR REGION>")).
WithCredential(auth).
Build())
request := &model.ShowPipelineLogRequest{}
request.JobRunId = "{job_run_id}"
request.StepRunId = "{step_run_id}"
request.ProjectId = "{project_id}"
request.PipelineId = "{pipeline_id}"
request.PipelineRunId = "{pipeline_run_id}"
endOffsetLogQuery:= int64(0)
startOffsetLogQuery:= int64(0)
request.Body = &model.LogQuery{
Sort: "asc",
Limit: int64(500),
EndOffset: &endOffsetLogQuery,
StartOffset: &startOffsetLogQuery,
}
response, err := client.ShowPipelineLog(request)
if err == nil {
fmt.Printf("%+v\n", response)
} else {
fmt.Println(err)
}
}
|
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
package com.huaweicloud.sdk.test;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.codeartspipeline.v2.region.CodeArtsPipelineRegion;
import com.huaweicloud.sdk.codeartspipeline.v2.*;
import com.huaweicloud.sdk.codeartspipeline.v2.model.*;
public class ShowPipelineLogSolution {
public static void main(String[] args) {
// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
String ak = System.getenv("CLOUD_SDK_AK");
String sk = System.getenv("CLOUD_SDK_SK");
ICredential auth = new BasicCredentials()
.withAk(ak)
.withSk(sk);
CodeArtsPipelineClient client = CodeArtsPipelineClient.newBuilder()
.withCredential(auth)
.withRegion(CodeArtsPipelineRegion.valueOf("<YOUR REGION>"))
.build();
ShowPipelineLogRequest request = new ShowPipelineLogRequest();
request.withJobRunId("{job_run_id}");
request.withStepRunId("{step_run_id}");
request.withProjectId("{project_id}");
request.withPipelineId("{pipeline_id}");
request.withPipelineRunId("{pipeline_run_id}");
LogQuery body = new LogQuery();
body.withSort("asc");
body.withLimit(500L);
body.withEndOffset(0L);
body.withStartOffset(0L);
request.withBody(body);
try {
ShowPipelineLogResponse response = client.showPipelineLog(request);
System.out.println(response.toString());
} catch (ConnectionException e) {
e.printStackTrace();
} catch (RequestTimeoutException e) {
e.printStackTrace();
} catch (ServiceResponseException e) {
e.printStackTrace();
System.out.println(e.getHttpStatusCode());
System.out.println(e.getRequestId());
System.out.println(e.getErrorCode());
System.out.println(e.getErrorMsg());
}
}
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# coding: utf-8
import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcodeartspipeline.v2.region.codeartspipeline_region import CodeArtsPipelineRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcodeartspipeline.v2 import *
if __name__ == "__main__":
# The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
# In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
ak = os.environ["CLOUD_SDK_AK"]
sk = os.environ["CLOUD_SDK_SK"]
credentials = BasicCredentials(ak, sk)
client = CodeArtsPipelineClient.new_builder() \
.with_credentials(credentials) \
.with_region(CodeArtsPipelineRegion.value_of("<YOUR REGION>")) \
.build()
try:
request = ShowPipelineLogRequest()
request.job_run_id = "{job_run_id}"
request.step_run_id = "{step_run_id}"
request.project_id = "{project_id}"
request.pipeline_id = "{pipeline_id}"
request.pipeline_run_id = "{pipeline_run_id}"
request.body = LogQuery(
sort="asc",
limit=500,
end_offset=0,
start_offset=0
)
response = client.show_pipeline_log(request)
print(response)
except exceptions.ClientRequestException as e:
print(e.status_code)
print(e.request_id)
print(e.error_code)
print(e.error_msg)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
package main
import (
"fmt"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
codeartspipeline "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2/model"
region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2/region"
)
func main() {
// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
ak := os.Getenv("CLOUD_SDK_AK")
sk := os.Getenv("CLOUD_SDK_SK")
auth := basic.NewCredentialsBuilder().
WithAk(ak).
WithSk(sk).
Build()
client := codeartspipeline.NewCodeArtsPipelineClient(
codeartspipeline.CodeArtsPipelineClientBuilder().
WithRegion(region.ValueOf("<YOUR REGION>")).
WithCredential(auth).
Build())
request := &model.ShowPipelineLogRequest{}
request.JobRunId = "{job_run_id}"
request.StepRunId = "{step_run_id}"
request.ProjectId = "{project_id}"
request.PipelineId = "{pipeline_id}"
request.PipelineRunId = "{pipeline_run_id}"
endOffsetLogQuery:= int64(0)
startOffsetLogQuery:= int64(0)
request.Body = &model.LogQuery{
Sort: "asc",
Limit: int64(500),
EndOffset: &endOffsetLogQuery,
StartOffset: &startOffsetLogQuery,
}
response, err := client.ShowPipelineLog(request)
if err == nil {
fmt.Printf("%+v\n", response)
} else {
fmt.Println(err)
}
}
|
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
Status Code |
Description |
---|---|
200 |
Response body for querying logs. |
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