1.4. 根据管道运行和任务运行的名称查询结果和日志
您可以使用 opc 命令行工具查询管道运行和任务运行列表的 Tekton Results,然后使用管道运行和任务运行的名称检索清单和日志信息。
与查询结果和记录相比,此方法需要不同的 opc 命令行工具配置。
根据管道运行和任务运行的名称查询结果和日志只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
1.4.1. 配置 opc 工具,以通过管道运行和任务运行名称查询结果 复制链接链接已复制到粘贴板!
在通过管道运行和任务运行名称查询 Tekton 结果的结果前,您必须配置 opc 工具。
先决条件
-
已安装
opc工具。 -
使用 OpenShift CLI (
oc)登录到 OpenShift Container Platform 集群。
流程
输入以下命令为 Tekton Results API 创建身份验证令牌:
$ oc create token <service_account>将 <
service_account> 替换为 OpenShift Container Platform 服务帐户的名称,该帐户对 OpenShift Pipelines 运行管道运行和任务运行的命名空间具有读访问权限。保存此命令输出的字符串。
完成以下步骤之一:
输入以下命令以互动方式配置
opc工具:$ opc results config set回复实用程序显示的提示。对于
Token,请输入您创建的身份验证令牌。输入以下命令从命令中配置
opc工具:$ opc results config set --host="https://tekton-results.example.com" --token="<token>"将主机名替换为 Tekton Results 路由的完全限定域名。将
<token> 替换为您生成的身份验证令牌。
验证
您可以输入以下命令来查看为
opc工具设置的配置:$ opc results config view输出示例
api-path: "" apiVersion: results.tekton.dev/v1alpha2 host: https://tekton-results.openshiftapps.com insecure-skip-tls-verify: "true" kind: Client token: sha256~xyz
1.4.2. 查看管道运行名称和标识符列表 复制链接链接已复制到粘贴板!
您可以使用 opc 实用程序查看在命名空间中运行的管道的名称和标识符列表。
先决条件
-
已安装
opc工具。 -
您已将
opc工具配置为通过管道运行和任务运行名称查询 Tekton Results 的结果。
流程
使用以下命令查看管道运行:
要查看指定命名空间中运行的所有管道,请输入以下命令:
$ opc results pipelinerun list -n <namespace_name>(可选)指定 the-
limit命令行选项,如--limit=10。使用这个设置时,opc 命令显示包含管道运行名称的指定行数,然后退出。如果您添加-single-page=false命令行选项,命令会显示指定的行数,然后提示您继续或退出。(可选)指定--
labels命令行选项,如--labels="app.kubernetes.io/name=test-app, app.kubernetes.io/component=database。使用这个设置时,列表只包含具有指定标签或注解的管道运行。opc results pipelinerun list命令的输出示例NAME UID STARTED DURATION STATUS openshift-pipelines-main-release-tests-zscq8 78515e3a-8e20-43e8-a064-d2442c2ae845 1 week ago 5s Failed(CouldntGetPipeline) openshift-pipelines-main-release-tests-zrgv6 14226144-2d08-440d-a600-d602ca46cdf6 1 week ago 26m13s Failed openshift-pipelines-main-release-tests-jdc24 e34daea2-66fb-4c7d-9d4b-d9d82a07b6cd 1 week ago 5s Failed(CouldntGetPipeline) openshift-pipelines-main-release-tests-6zj7f 9b3e5d68-70ab-4c23-8872-e7ad7121e60b 1 week ago 5s Failed(CouldntGetPipeline) openshift-pipelines-main-release-tests-kkk9t 2fd28c48-388b-4e6a-9ec3-2bcd9dedebc3 1 week ago 5s Failed(CouldntGetPipeline)要查看与指定管道相关的管道运行,请输入以下命令:
$ opc results pipelinerun list <pipeline_name> -n <namespace_name>命令列出包含 <
pipeline_name> 的管道的所有管道运行。例如,如果指定build,命令显示所有与名为 build、或build_123enhancedbuild的管道相关的管道运行。(可选)指定 the-
limit命令行选项,如--limit=10。使用这个设置时,opc 命令显示包含管道运行名称的指定行数,然后退出。如果您添加-single-page=false命令行选项,命令会显示指定的行数,然后提示您继续或退出。
1.4.3. 查看任务运行名称和标识符列表 复制链接链接已复制到粘贴板!
您可以使用 opc 实用程序查看在命名空间中运行的任务列表,或与管道 dun 关联的任务运行。
先决条件
-
已安装
opc工具。 -
您已将
opc工具配置为通过管道运行和任务运行名称查询 Tekton Results 的结果。
流程
要查看命名空间中运行的所有任务的列表,请输入以下命令:
$ opc results taskrun list -n <namespace_name>(可选)指定 the-
limit命令行选项,如--limit=10。使用这个设置时,opc 命令显示包含管道运行名称的指定行数,然后退出。如果您添加-single-page=false命令行选项,命令会显示指定的行数,然后提示您继续或退出。(可选)指定--
labels参数,如--labels="app.kubernetes.io/name=test-app, app.kubernetes.io/component=database。使用这个设置时,列表只包含具有指定标签或注解的任务运行。命名空间的
opc results pipelinerun list命令的输出示例NAME UID STARTED DURATION STATUS openshift-pipelines-main-release-tests-zrgv6-e2e-test 10d6952f-b926-4e4b-a976-519867969ce7 16d ago 12m41s Failed openshift-pipelines-main-release-tests-zrgv6-deploy-operator ab41b63b-16ec-4a32-8b95-f2678eb5c945 16d ago 22s Succeeded openshift-pipelines-main-release-tests-zrgv6-provision-cluster b374df00-5132-4633-91df-3259670756b3 16d ago 12m30s Succeeded operator-main-index-4-18-on-pull-request-ml4ww-show-sbom c5b77784-cd87-4be8-bc12-28957762f382 16d ago 16s Succeeded openshift-c4ae3a5a28e19ffc930e7c2aa758d85c-provision-eaas-space 22535d8e-d360-4143-9c0c-4bd0414a22b0 16d ago 17s Succeeded要查看与管道运行关联的任务运行列表,请输入以下命令:
$ opc results taskrun list --pipelinerun <pipelinerun_name> -n <namespace_name>(可选)指定 the-
limit命令行选项,如--limit=10。使用这个设置时,opc 命令显示包含管道运行名称的指定行数,然后退出。如果您添加-single-page=false命令行选项,命令会显示指定的行数,然后提示您继续或退出。
管道运行的 opc results taskrun list 命令的输出示例
+
NAME UID STARTED DURATION STATUS
operator-main-index-4-18-on-pull-request-g95fk-show-sbom 5b405941-0d3e-4f8c-a68a-9ffcc481abf1 16d ago 13s Succeeded
operator-main-index-4-18-on-pul2b222db723593a186d12f1b82f1a1fd9 89588ae7-aa36-4b62-97d1-5634ee201850 16d ago 36s Succeeded
operator-fb80434867bc15d89fea82506058f664-fbc-fips-check-oci-ta 7598d44a-4370-459b-8ef0-ae4165c58ba5 16d ago 5m52s Succeeded
operator-main-index-4-18-on-pull-request-g95fk-validate-fbc fb80d962-807b-4b63-80cb-6a57d383755a 16d ago 1m26s Succeeded
operator-main-index-4-18-on-pull-request-g95fk-apply-tags 8a34b46d-74a9-4f20-9e99-a285f7b258d6 16d ago 13s Succeeded
1.4.4. 查看管道运行的结果信息 复制链接链接已复制到粘贴板!
您可以使用 opc 实用程序查看管道运行完成的描述,以及管道运行的完整清单,以及管道运行生成的日志。
先决条件
-
已安装
opc工具。 -
您已将
opc工具配置为通过管道运行和任务运行名称查询 Tekton Results 的结果。 -
您有管道运行的名称或 UUID。您可以使用
ocp results list pipelineruns命令来查看可用结果的管道运行的名称和 UUID。
流程
使用以下命令查看管道运行的结果信息:
要查看有关管道运行完成的时间和方式的描述,请输入以下命令:
$ opc results pipelinerun describe -n <namespace_name> <pipelinerun_name>另外,您可以使用管道运行 UUID 而不是名称:
$ opc results pipelinerun describe -n <namespace_name> --uid <pipelinerun_uuid>opc results pipelinerun describe命令的输出示例Name: operator-main-index-4-18-on-pull-request-7kssl Namespace: tekton-ecosystem-tenant Service Account: appstudio-pipeline Labels: app.kubernetes.io/managed-by=pipelinesascode.tekton.dev app.kubernetes.io/version=v0.33.0 Annotations: appstudio.openshift.io/snapshot=openshift-pipelines-main-b7jj6 build.appstudio.openshift.io/repo=https://github.com/openshift-pipelines/operator?rev=ba5e62e51af0c88bc6c3fd4201e789bdfc093daa 📌 Status STARTED DURATION STATUS 27d ago 9m54s Succeeded ⏱ Timeouts Pipeline: 2h0m0s ⚓ Params NAME VALUE • git-url https://github.com/pramodbindal/operator • revision ba5e62e51af0c88bc6c3fd4201e789bdfc093daa 🗂 Workspaces NAME SUB PATH WORKSPACE BINDING • workspace --- VolumeClaimTemplate • git-auth --- Secret (secret=pac-gitauth-ceqzjt) 📦 Taskruns NAME TASK NAME • operator-main-index-4-18-on-pull-request-7kssl-init init • operator-main-index-4-18-on-pull-request-7kssl-clone-repository clone-repository
要查看管道运行的完整 YAML 清单,请输入以下命令:
$ opc results pipelinerun describe -n <namespace_name> --output yaml <pipelinerun_name>另外,您可以使用管道运行 UUID 而不是名称:
$ opc results pipelinerun describe -n <namespace_name> --output yaml --uid <pipelinerun_uuid>要查看与管道运行关联的日志,请输入以下命令:
$ opc results pipelinerun logs -n <namespace_name> <pipelinerun_name>另外,您可以使用管道运行 UUID 而不是名称:
$ opc results pipelinerun logs -n <namespace_name> --uid <pipelinerun_uuid>
opc results pipelinerun 日志显示的日志 不包括在这个管道运行中完成的任务运行的日志。要查看这些日志,请使用 opc results taskrun list --pipelinerun 命令查找在此管道运行中运行的任务名称,并指定管道运行的名称。然后,使用 opc results taskrun log 命令查看任务运行的日志。
1.4.5. 查看任务运行的结果信息 复制链接链接已复制到粘贴板!
您可以使用 opc 实用程序查看任务运行完成的描述,以及任务运行的完整清单,以及任务运行生成的日志。
先决条件
-
已安装
opc工具。 -
您已将
opc工具配置为通过管道运行和任务运行名称查询 Tekton Results 的结果。 -
您有任务运行的名称或 UUID。您可以使用
opc results taskrun list命令查看可用结果的任务运行的名称或 UUID。 - 如果要检索日志,配置了将日志转发到 LokiStack。
流程
使用以下命令查看任务运行的结果信息:
要查看有关任务运行完成的时间和方式的描述,请输入以下命令:
$ opc results taskrun describe -n <namespace_name> <taskrun_name>另外,您可以使用任务运行 UUID 而不是名称:
$ opc results taskrun describe -n <namespace_name> --uid <taskrun_uuid>opc 结果 taskrun describe命令的输出示例Name: operator-main-index-4-18-on-push-gc699-build-images-0 Namespace: tekton-ecosystem-tenant Service Account: appstudio-pipeline Labels: tekton.dev/pipelineTask=build-images tekton.dev/task=buildah-remote-oci-ta Annotations: pipelinesascode.tekton.dev/branch=main pipelinesascode.tekton.dev/check-run-id=40080193061 📌 Status STARTED DURATION STATUS 28d ago 3m22s Failed ⚓ Params NAME VALUE • PLATFORM linux-m2xlarge/arm64 • IMAGE quay.io/redhat-user-workloads/tekton-ecosystem
要查看任务运行的完整 YAML 清单,请输入以下命令:
$ opc results taskrun describe -n <namespace_name> --output yaml <taskrun_name>另外,您可以使用任务运行 UUID 而不是名称:
$ opc results taskrun describe -n <namespace_name> --output yaml --uid <taskrun_uuid>要查看与任务运行关联的日志,请输入以下命令:
$ opc results taskrun logs -n <namespace_name> <taskrun_name>另外,您可以使用任务运行 UUID 而不是名称:
$ opc results taskrun logs -n <namespace_name> --uid <taskrun_uuid>
1.4.6. 命令行参数的短名称 复制链接链接已复制到粘贴板!
当使用 opc 工具通过管道运行和任务运行名称查询 Tekton Results 的结果时,您可以将长命令行参数替换为其名称的简短版本。
| 完整参数名称 | 短参数名称 |
|---|---|
|
|
|
|
|
|
|
|
|