Matrix is used to fan out Tasks in a Pipeline. This doc will explain the details of matrix support in
Tekton.
🌱
Matrixis an alpha feature. Theenable-api-fieldsfeature flag must be set to"alpha"to specifyMatrixin aPipelineTask.
⚠️ This feature is in a preview mode. It is still in a very early stage of development and is not yet fully functional.
A Matrix supports the following features:
The Matrix will take Parameters of type "array" only, which will be supplied to the
PipelineTask by substituting Parameters of type "string" in the underlying Task.
The names of the Parameters in the Matrix must match the names of the Parameters
in the underlying Task that they will be substituting.
In the example below, the test Task takes browser and platform Parameters of type
"string". A Pipeline used to fan out the Task using Matrix would have two Parameters
of type "array", and it would execute nine TaskRuns:
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: platform-browser-tests
spec:
params:
- name: platforms
type: array
default:
- linux
- mac
- windows
- name: browsers
type: array
default:
- chrome
- safari
- firefox
tasks:
- name: fetch-repository
taskRef:
name: git-clone
...
- name: test
matrix:
- name: platform
value: $(params.platforms)
- name: browser
value: $(params.browsers)
taskRef:
name: browser-test
...A Parameter can be passed to either the matrix or params field, not both.
For further details on specifying Parameters in the Pipeline and passing them to
PipelineTasks, see documentation.
Similarly to the Parameters in the Params field, the Parameters in the Matrix field will accept
context variables that will be substituted, including:
PipelineRunname, namespace and uidPipelinenamePipelineTaskretries