3.4. カスタムタスクとスクリプトを使用した OpenShift Pipelines 機能の拡張
OpenShift Pipelines では、Tekton Hub で適切なタスクが見つからない場合、またはタスクをより細かく制御する必要がある場合は、カスタムタスクとスクリプトを作成して OpenShift Pipelines の機能を拡張できます。
例: maven test コマンドを実行するカスタムタスク
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: maven-test
spec:
workspaces:
- name: source
steps:
- image: my-maven-image
command: ["mvn test"]
workingDir: $(workspaces.source.path)
例: パスを指定してカスタムシェルスクリプトを実行する
...
steps:
image: ubuntu
script: |
#!/usr/bin/env bash
/workspace/my-script.sh
...
例: カスタム Python スクリプトを YAML ファイルに書き込んで実行する
...
steps:
image: python
script: |
#!/usr/bin/env python3
print(“hello from python!”)
...