Matrix is a beta feature. Set
enable-api-fields to "beta" to use this feature.Overview
A Matrix allows you to:- Generate parameter combinations automatically using
Matrix.Params - Specify explicit combinations using
Matrix.Include - Fan out both regular Tasks and Custom Tasks
- Control concurrency of parallel executions
- Aggregate results from all fanned-out TaskRuns
Generating Combinations
UseMatrix.Params to automatically generate all combinations of the specified parameter values:
Adding Explicit Combinations
UseMatrix.Include to add specific combinations or augment existing ones:
include clause adds the url parameter to all combinations with platform: linux. The second adds a new combination:
Using Include Without Params
You can useMatrix.Include alone to specify exact combinations without auto-generation:
Complete Example
Here’s a complete example that creates nine TaskRuns from a matrix of platforms and browsers:Concurrency Control
The default maximum number of TaskRuns from a Matrix is 256. Configure this inconfig-defaults.yaml:
Using Parameters
String and Array Replacements
Matrix.Params supports replacements from Pipeline parameters:
Combining Params and Matrix
You can use bothparams and matrix in a PipelineTask:
platform: linux and different browser values.
A parameter can be passed to either
matrix or params, but not both.Working with Results
Consuming Results in Matrix
You can use results from previous Tasks to generate matrix combinations:Emitting Results from Matrix
Each TaskRun in a fanned-out PipelineTask can emit string results, which are aggregated into an array:Context Variables
Matrix Length
Access the total number of TaskRuns created by a matrix:Aggregated Results Length
Access the length of aggregated result arrays:Display Names
Customize the display name of each matrix instance using parameters:displayName appears in pipelineRun.status.childReferences:
matrix.include[] which take precedence over displayName:
Retries
When a PipelineTask with a Matrix specifiesretries, each individual TaskRun is retried independently:
Advanced Example: Go Build Matrix
Here’s a complex example using bothMatrix.Params and Matrix.Include for Go builds across architectures: