This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.4.5. 组装 Pipeline
一个 Pipeline 代表一个 CI/CD 流,由要执行的任务定义。它通过 inputs、outputs 和 runAfter 参数来指定不同的任务间如何进行交互以及它们执行的顺序。它被设计为在多个应用程序和环境中通用且可重复使用。
在本小节中,您将创建一个 Pipeline,从 GitHub 获取应用程序的源代码,然后在 OpenShift Container Platform 上构建和部署应用程序。
Pipeline 为后端应用程序 vote-api 和前端应用程序 vote-ui 执行以下任务:
-
从 Git 存储库
api-repo和ui-repo中克隆应用程序的源代码。 -
使用
buildahClusterTask 构建容器镜像api-image和ui-image。 -
将
api-image和ui-image镜像推送到内部镜像 registry。 -
使用
apply-manifests和update-deployment任务在 OpenShift Container Platform 上部署新镜像。
流程
复制以下 Pipeline YAML 文件示例内容并保存:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 请注意,Pipeline 定义提取了要在 Pipeline 执行过程中使用的 Git 源存储库和镜像 registry 的特定内容。
创建 Pipeline:
oc create -f <pipeline-yaml-file-name.yaml>
$ oc create -f <pipeline-yaml-file-name.yaml>Copy to Clipboard Copied! Toggle word wrap Toggle overflow 或者,还可以从 Git 存储库直接执行 YAML 文件:
oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/release-tech-preview-1/01_pipeline/04_pipeline.yaml
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/release-tech-preview-1/01_pipeline/04_pipeline.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow 使用
tkn pipeline list命令来验证是否在应用程序中添加了 Pipeline:tkn pipeline list
$ tkn pipeline listCopy to Clipboard Copied! Toggle word wrap Toggle overflow 检查输出来验证创建了
build-and-deployPipeline:NAME AGE LAST RUN STARTED DURATION STATUS build-and-deploy 1 minute ago --- --- --- ---
NAME AGE LAST RUN STARTED DURATION STATUS build-and-deploy 1 minute ago --- --- --- ---Copy to Clipboard Copied! Toggle word wrap Toggle overflow