3.2.2. OpenShift Pipelines パイプライン
前の Jenkins パイプラインと同等のパイプラインを OpenShift Pipelines で作成するには、次の 3 つのタスクを作成します。
build タスクの YAML 定義ファイルの例
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: myproject-build
spec:
workspaces:
- name: source
steps:
- image: my-ci-image
command: ["make"]
workingDir: $(workspaces.source.path)
test タスクの YAML 定義ファイルの例
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: myproject-test
spec:
workspaces:
- name: source
steps:
- image: my-ci-image
command: ["make check"]
workingDir: $(workspaces.source.path)
- image: junit-report-image
script: |
#!/usr/bin/env bash
junit-report reports/**/*.xml
workingDir: $(workspaces.source.path)
deploy タスクの YAML 定義ファイルの例
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: myprojectd-deploy
spec:
workspaces:
- name: source
steps:
- image: my-deploy-image
command: ["make deploy"]
workingDir: $(workspaces.source.path)
3 つのタスクを順番に組み合わせて、OpenShift Pipelines でパイプラインを形成できます。
例: ビルド、テスト、およびデプロイのための OpenShift Pipelines
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: myproject-pipeline
spec:
workspaces:
- name: shared-dir
tasks:
- name: build
taskRef:
name: myproject-build
workspaces:
- name: source
workspace: shared-dir
- name: test
taskRef:
name: myproject-test
workspaces:
- name: source
workspace: shared-dir
- name: deploy
taskRef:
name: myproject-deploy
workspaces:
- name: source
workspace: shared-dir