-
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.
Add context variables for PipelineRun and TaskRun UIDs
A user may want to tag an oci image with the TaskRun or PipelineRun UIDs. Currently, they can't do that because `metadata.uid` for TaskRuns and PipelineRuns are not exposed. In this PR, we add the UID context variable for TaskRuns and PipelineRun. Users can now use `$(context.taskRun.uid)` and `$(context.pipelineRun.uid)` to access and use UIDs. In addition, we add validation for all context variables that are supported so far -- `context.task.name`, `context.taskRun.name`, `context.taskRun.namespace`, `context.taskRun.uid`, `context.pipeline.name`, `context.pipelineRun.name`, `context.pipelineRun.namespace`, `context.pipelineRun.uid`. Partially fixes #2958
- Loading branch information
Showing
13 changed files
with
345 additions
and
10 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
34 changes: 34 additions & 0 deletions
34
examples/v1beta1/pipelineruns/using_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,34 @@ | ||
kind: PipelineRun | ||
apiVersion: tekton.dev/v1beta1 | ||
metadata: | ||
generateName: test-pipelinerun- | ||
spec: | ||
serviceAccountName: 'default' | ||
pipelineSpec: | ||
tasks: | ||
- name: task1 | ||
params: | ||
- name: pipeline-uid | ||
value: "$(context.pipelineRun.uid)" | ||
- name: pipeline-name | ||
value: "$(context.pipeline.name)" | ||
- name: pipelineRun-name | ||
value: "$(context.pipelineRun.name)" | ||
taskSpec: | ||
params: | ||
- name: pipeline-uid | ||
- name: pipeline-name | ||
- name: pipelineRun-name | ||
steps: | ||
- image: ubuntu | ||
name: print-uid | ||
script: | | ||
echo "TaskRun UID: $(context.taskRun.uid)" | ||
echo "PipelineRun UID from params: $(params.pipeline-uid)" | ||
- image: ubuntu | ||
name: print-names | ||
script: | | ||
echo "Task name: $(context.task.name)" | ||
echo "TaskRun name: $(context.taskRun.name)" | ||
echo "Pipeline name from params: $(params.pipeline-name)" | ||
echo "PipelineRun name from params: $(params.pipelineRun-name)" |
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,16 @@ | ||
kind: TaskRun | ||
apiVersion: tekton.dev/v1beta1 | ||
metadata: | ||
generateName: test-taskrun- | ||
spec: | ||
taskSpec: | ||
steps: | ||
- image: ubuntu | ||
name: print-uid | ||
script: | | ||
echo "TaskRunUID name: $(context.taskRun.uid)" | ||
- image: ubuntu | ||
name: print-names | ||
script: | | ||
echo "Task name: $(context.task.name)" | ||
echo "TaskRun name: $(context.taskRun.name)" |
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
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
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
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
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
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
Oops, something went wrong.