In Tekton, if you do not find the right task in Tekton Hub, or need greater control over tasks, you can create custom tasks and scripts to extend Tekton’s capabilities.
Example: Custom task for running the maven test
command
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)
Example: Execute a custom shell script by providing its path
...
steps:
image: ubuntu
script: |
#!/usr/bin/env bash
/workspace/my-script.sh
...
Example: Execute a custom Python script by writing it in the YAML file
...
steps:
image: python
script: |
#!/usr/bin/env python3
print(“hello from python!”)
...