Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions examples/v1beta1/pipelineruns/alpha/pipeline-object-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: mock-clone-task
spec:
params:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at examples/v1beta1/pipelineruns/alpha/pipeline-emitting-results.yaml together, I realize another example is missing is that: a task is using a previous task's results in the params as a whole. Example with object keys: https://github.com/tektoncd/pipeline/blob/main/examples/v1beta1/pipelineruns/task_results_example.yaml and https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#passing-one-tasks-results-into-the-parameters-or-when-expressions-of-another

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is the example for object param only. Object result (i.e. using a previous task's object result) example is in the file /pipeline-object-results.yaml.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SG!

- name: arg
type: object
properties:
url:
type: string
commit:
type: string
steps:
- name: mock-clone-git
image: bash
args: [
"echo",
"--url=$(params.arg.url)",
"--commit=$(params.arg.commit)"
]
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: mock-clone-pipeline
spec:
params:
- name: gitrepo
properties:
url: {}
commit: {}
tasks:
- name: mock-clone
params:
- name: arg
value: $(params.gitrepo[*])
taskRef:
name: mock-clone-task
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: pipelinerun-object-param-
spec:
params:
- name: gitrepo
value:
url: abc.com
commit: sha123
pipelineRef:
name: mock-clone-pipeline
36 changes: 36 additions & 0 deletions examples/v1beta1/taskruns/alpha/object-param-result.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: object-param-result-
spec:
params:
- name: gitrepo
value:
url: "xyz.com"
commit: "sha123"
taskSpec:
params:
- name: gitrepo
type: object
properties:
url: {type: string}
commit: {type: string}
results:
- name: object-results
type: object
properties:
IMAGE_URL: {type: string}
IMAGE_DIGEST: {type: string}
steps:
- name: echo-object-params
image: bash
args: [
"echo",
"--url=$(params.gitrepo.url)",
"--commit=$(params.gitrepo.commit)"
]
- name: write-object-result
image: bash:latest
script: |
#!/usr/bin/env bash
echo -n "{\"IMAGE_URL\":\"ar.com\", \"IMAGE_DIGEST\":\"sha234\"}" > $(results.object-results.path)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind adding another reference to a object param key to replace ar.com in script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sg!