-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit enables producing Results from Matrixed PipelineTasks so that they can be used in subsequent PipelineTasks. A Pipeline author can now declare a matrixed taskRun that emits results of type string that are fanned out over multiple taskRuns and aggregated into an array of results that can then be consumed by another pipelineTask using the syntax `$(tasks.<pipelineTaskName>.results.<resultName>[*])`. This commit also introduces 2 context variables to 1) Access Matrix Combinations Length using `tasks.<pipelineTaskName>.matrix.length` and 2) Access Aggregated Results Length using `tasks.<pipelineTaskName>.matrix.<resultName>.length` Note: Currently, we don't support consuming a single instance/combinations of results. Authors must consume the entire aggregated results array.
- Loading branch information
1 parent
cbabe7f
commit c04d0df
Showing
19 changed files
with
3,272 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
examples/v1/pipelineruns/alpha/pipelinerun-with-matrix-context-variables.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: echomatrixlength | ||
spec: | ||
params: | ||
- name: matrixlength | ||
type: string | ||
steps: | ||
- name: echo | ||
image: alpine | ||
script: echo $(params.matrixlength) | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: echomatrixresultslength | ||
spec: | ||
params: | ||
- name: matrixresultslength | ||
type: string | ||
steps: | ||
- name: echo | ||
image: alpine | ||
script: echo $(params.matrixresultslength) | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: taskwithresults | ||
spec: | ||
params: | ||
- name: IMAGE | ||
- name: DIGEST | ||
default: "" | ||
results: | ||
- name: IMAGE-DIGEST | ||
steps: | ||
- name: produce-results | ||
image: bash:latest | ||
script: | | ||
#!/usr/bin/env bash | ||
echo "Building image for $(params.IMAGE)" | ||
echo -n "$(params.DIGEST)" | sha256sum | tee $(results.IMAGE-DIGEST.path) | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
generateName: matrix-emitting-results | ||
spec: | ||
serviceAccountName: "default" | ||
pipelineSpec: | ||
tasks: | ||
- name: matrix-emitting-results | ||
matrix: | ||
include: | ||
- name: build-1 | ||
params: | ||
- name: IMAGE | ||
value: image-1 | ||
- name: DOCKERFILE | ||
value: path/to/Dockerfile1 | ||
- name: build-2 | ||
params: | ||
- name: IMAGE | ||
value: image-2 | ||
- name: DOCKERFILE | ||
value: path/to/Dockerfile2 | ||
- name: build-3 | ||
params: | ||
- name: IMAGE | ||
value: image-3 | ||
- name: DOCKERFILE | ||
value: path/to/Dockerfile3 | ||
taskRef: | ||
name: taskwithresults | ||
kind: Task | ||
- name: matrixed-echo-length | ||
runAfter: | ||
- matrix-emitting-results | ||
params: | ||
- name: matrixlength | ||
value: $(tasks.matrix-emitting-results.matrix.length) | ||
taskRef: | ||
name: echomatrixlength | ||
kind: Task | ||
- name: matrixed-echo-results-length | ||
runAfter: | ||
- matrix-emitting-results | ||
params: | ||
- name: matrixresultslength | ||
value: $(tasks.matrix-emitting-results.matrix.IMAGE-DIGEST.length) | ||
taskRef: | ||
name: echomatrixresultslength | ||
kind: Task |
90 changes: 90 additions & 0 deletions
90
examples/v1/pipelineruns/alpha/pipelinerun-with-matrix-emitting-results.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: echostringurl | ||
spec: | ||
params: | ||
- name: url | ||
type: string | ||
steps: | ||
- name: echo | ||
image: alpine | ||
script: | | ||
echo "$(params.url)" | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: echoarrayurl | ||
spec: | ||
params: | ||
- name: url | ||
type: array | ||
steps: | ||
- name: use-environments | ||
image: bash:latest | ||
args: ["$(params.url[*])"] | ||
script: | | ||
for arg in "$@"; do | ||
echo "URL: $arg" | ||
done | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: taskwithresults | ||
spec: | ||
params: | ||
- name: platform | ||
default: "" | ||
- name: browser | ||
default: "" | ||
results: | ||
- name: report-url | ||
type: string | ||
steps: | ||
- name: produce-report-url | ||
image: alpine | ||
script: | | ||
echo "Running tests on $(params.platform)-$(params.browser)" | ||
echo -n "https://api.example/get-report/$(params.platform)-$(params.browser)" | tee $(results.report-url.path) | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
generateName: platforms-with-results | ||
spec: | ||
serviceAccountName: "default" | ||
pipelineSpec: | ||
tasks: | ||
- name: matrix-emitting-results | ||
matrix: | ||
params: | ||
- name: platform | ||
value: | ||
- linux | ||
- mac | ||
- windows | ||
- name: browser | ||
value: | ||
- chrome | ||
- safari | ||
- firefox | ||
taskRef: | ||
name: taskwithresults | ||
kind: Task | ||
- name: task-consuming-results | ||
taskRef: | ||
name: echoarrayurl | ||
kind: Task | ||
params: | ||
- name: url | ||
value: $(tasks.matrix-emitting-results.results.report-url[*]) | ||
- name: matrix-consuming-results | ||
taskRef: | ||
name: echostringurl | ||
kind: Task | ||
matrix: | ||
params: | ||
- name: url | ||
value: $(tasks.matrix-emitting-results.results.report-url[*]) |
Oops, something went wrong.