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)
示例:通过提供自定义 shell 脚本的路径
...
steps:
image: ubuntu
script: |
#!/usr/bin/env bash
/workspace/my-script.sh
...
示例:在 YAML 文件中写入自定义 Python 脚本
...
steps:
image: python
script: |
#!/usr/bin/env python3
print(“hello from python!”)
...