3.5.6. 运行管道

PipelineRun 资源启动管道,并将其与 Git 和用于特定调用的镜像资源相关联。它为管道中的每个任务自动创建并启动 TaskRun 资源。

流程

  1. 启动后端应用程序的管道:

    $ tkn pipeline start build-and-deploy \
        -w name=shared-workspace,volumeClaimTemplateFile=https://raw.githubusercontent.com/openshift/pipelines-tutorial/pipelines-1.4/01_pipeline/03_persistent_volume_claim.yaml \
        -p deployment-name=pipelines-vote-api \
        -p git-url=https://github.com/openshift/pipelines-vote-api.git \
        -p IMAGE=image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/pipelines-vote-api

    上一命令使用卷声明模板,该模板为管道执行创建持久性卷声明。

  2. 要跟踪管道运行的进度,请输入以下命令:

    $ tkn pipelinerun logs <pipelinerun_id> -f

    上述命令中的 <pipelinerun_id> 是上一命令输出返回的 PipelineRun 的 ID。

  3. 启动前端应用程序的管道:

    $ tkn pipeline start build-and-deploy \
        -w name=shared-workspace,volumeClaimTemplateFile=https://raw.githubusercontent.com/openshift/pipelines-tutorial/pipelines-1.4/01_pipeline/03_persistent_volume_claim.yaml \
        -p deployment-name=pipelines-vote-ui \
        -p git-url=https://github.com/openshift/pipelines-vote-ui.git \
        -p IMAGE=image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/pipelines-vote-ui
  4. 要跟踪管道运行的进度,请输入以下命令:

    $ tkn pipelinerun logs <pipelinerun_id> -f

    上述命令中的 <pipelinerun_id> 是上一命令输出返回的 PipelineRun 的 ID。

  5. 几分钟后,使用 tkn pipelinerun list 命令列出所有管道运行来验证管道是否成功运行:

    $ tkn pipelinerun list

    输出列出了管道运行:

     NAME                         STARTED      DURATION     STATUS
     build-and-deploy-run-xy7rw   1 hour ago   2 minutes    Succeeded
     build-and-deploy-run-z2rz8   1 hour ago   19 minutes   Succeeded
  6. 获取应用程序路由:

    $ oc get route pipelines-vote-ui --template='http://{{.spec.host}}'

    记录上一个命令的输出。您可以使用此路由来访问应用程序。

  7. 要重新运行最后的管道运行,请使用上一管道的管道资源和服务帐户运行:

    $ tkn pipeline start build-and-deploy --last