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 フローを表し、実行する Task によって定義されます。これは、inputs
、outputs
、および runAfter
パラメーターを使用して Task が相互に対話する方法および実行順序を指定します。これは、複数のアプリケーションや環境で汎用的かつ再利用可能になるように設計されています。
このセクションでは、GitHub からアプリケーションのソースコードを取り、これを OpenShift Container Platform にビルドし、デプロイする Pipeline を作成します。
Pipeline は、バックエンドアプリケーションの vote-api
およびフロントエンドアプリケーションの vote-ui
について以下のタスクを実行します。
-
Git リポジトリー
api-repo
およびui-repo
からアプリケーションのソースコードのクローンを作成します。 -
buildah
ClusterTask を使用してコンテナーイメージapi-image
およびui-image
をビルドします。 -
api-image
およびui-image
イメージを内部イメージレジストリーにプッシュします。 -
apply-manifests
およびupdate-deployment
Task を使用して新規イメージを OpenShift Container Platform にデプロイします。
手順
以下のサンプルの Pipeline YAML ファイルの内容をコピーし、保存します。
apiVersion: tekton.dev/v1beta1 kind: Pipeline metadata: name: build-and-deploy spec: resources: - name: git-repo type: git - name: image type: image params: - name: deployment-name type: string description: name of the deployment to be patched tasks: - name: build-image taskRef: name: buildah kind: ClusterTask resources: inputs: - name: source resource: git-repo outputs: - name: image resource: image params: - name: TLSVERIFY value: "false" - name: apply-manifests taskRef: name: apply-manifests resources: inputs: - name: source resource: git-repo runAfter: - build-image - name: update-deployment taskRef: name: update-deployment resources: inputs: - name: image resource: image params: - name: deployment value: $(params.deployment-name) runAfter: - apply-manifests
Pipeline 定義は、Pipeline の実行時に使用される Git ソースリポジトリーおよびイメージレジストリーの詳細を抽象化します。
Pipeline を作成します。
$ oc create -f <pipeline-yaml-file-name.yaml>
または、Git リポジトリーから YAML ファイルを直接実行することもできます。
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/release-tech-preview-1/01_pipeline/04_pipeline.yaml
tkn pipeline list
コマンドを使用して、Pipeline がアプリケーションに追加されていることを確認します。$ tkn pipeline list
この出力では、
build-and-deploy
Pipeline が作成されていることを検証します。NAME AGE LAST RUN STARTED DURATION STATUS build-and-deploy 1 minute ago --- --- --- ---