Writing your own tasks - michaelsauter/ods-pipeline GitHub Wiki
This section will guide you through the basics of writing your own Tekton task.
Before you can write the task, you need to know which image(s) to use. You may use existing images (e.g. from DockerHub or registry.redhat.io), or you build your own (e.g. by using BuildConfig
and ImageStream
resources in your OpenShift namespace).
Next, you can either start writing a task from scratch (in the OpenShift console under "Pipelines > Tasks") or copy an existing task (such as an ODS ClusterTask
resource) and modify this task according to your needs.
For further information on how to author tasks, see the Tekton task documentation.
In the introduction above, you have seen that ODS tasks may upload artefacts to Nexus, so that later tasks or pipeline runs can make use of them. To this end, ODS tasks use a few binaries in the container image to communicate with Nexus. To do the same in your task, you can either base your image on an ODS base image that has these binaries available, or you install the binaries directly in your image, or you add a task step at the end of your new task which uses the ODS base image to upload artefacts created in previous steps.
Finally, once you have created your task in OpenShift, you can reference it in the same way you are referencing other tasks in your ods.yml
file from which you want to use the task.
There is also a shortcut that avoids having to define an independent Task
resource in OpenShift: you can simply put the task spec into ods.yml
. Example:
phases:
init:
- name: hello-world
taskSpec:
steps:
- image: alpine
name: say-hello-world
script: echo hello world
Again, refer to the Tekton task documentation for further information.