Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pritidesai/931936e2bd61c50df29fdc767442b494 to your computer and use it in GitHub Desktop.
Save pritidesai/931936e2bd61c50df29fdc767442b494 to your computer and use it in GitHub Desktop.
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: sum-two-ints
annotations:
description: |
A simple task that sums the two provided integers
spec:
params:
- name: a
type: string
default: "1"
description: The first integer
- name: b
type: string
default: "1"
description: The second integer
results:
- name: sum-result
description: The sum of the two provided integers
steps:
- name: sum
image: bash:latest
script: |
#!/usr/bin/env bash
echo $(params.a)
echo $(params.b)
# echo -n $(( "$(params.a)" + "$(params.b)" )) | tee $(results.sum-result.path)
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: format-result
spec:
params:
- name: result
type: string
steps:
- name: print-sum
image: ubuntu
script: echo -n "*** Result = $(params.result) ***"
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: sum-and-print-pipeline
spec:
params:
- name: a
type: string
default: "1"
- name: b
type: string
default: "1"
tasks:
- name: sum-inputs
taskRef:
name: sum-two-ints
params:
- name: a
value: "$(params.a)"
- name: b
value: "$(params.b)"
- name: print-sum
taskRef:
name: format-result
params:
- name: result
value: "$(tasks.sum-inputs.results.sum-result)"
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: sum-and-print-pipeline-run
spec:
pipelineRef:
name: sum-and-print-pipeline
params:
- name: a
value: "100"
- name: b
value: "1000"
---
@pritidesai
Copy link
Author

pritidesai commented Apr 29, 2020

This pipeline fails with PipelineValidationFailed as sum-result is not initialized by the task sum-two-ints where its declared, note echo is commented here.

tkn pr describe sum-and-print-pipeline-run
Name:           sum-and-print-pipeline-run
Namespace:      default
Pipeline Ref:   sum-and-print-pipeline

🌡️  Status

STARTED          DURATION    STATUS
57 seconds ago   6 seconds   Failed(PipelineValidationFailed)

💌 Message

unable to find result referenced by param "result" in "print-sum": Could not find result with name sum-result for task run sum-inputs

📦 Resources

 No resources

⚓ Params

 NAME   VALUE
 ∙ a    100
 ∙ b    1000

🗂  Taskruns

 NAME                                            TASK NAME    STARTED          DURATION    STATUS
 ∙ sum-and-print-pipeline-run-sum-inputs-fhcjx   sum-inputs   57 seconds ago   6 seconds   Succeeded

@pritidesai
Copy link
Author

Pod is created for sum-inputs without any failure:

kubectl logs pod/sum-and-print-pipeline-run-sum-inputs-fhcjx-pod-5jhvd --all-containers
100
1000

@pritidesai
Copy link
Author

{
    "apiVersion": "v1",
    "items": [
        {
            "apiVersion": "tekton.dev/v1beta1",
            "kind": "PipelineRun",
            "metadata": {
                "annotations": {
                    "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"tekton.dev/v1beta1\",\"kind\":\"Pipeline\",\"metadata\":{\"annotations\":{},\"name\":\"sum-and-print-pipeline\",\"namespace\":\"default\"},\"spec\":{\"params\":[{\"default\":\"1\",\"name\":\"a\",\"type\":\"string\"},{\"default\":\"1\",\"name\":\"b\",\"type\":\"string\"}],\"tasks\":[{\"name\":\"sum-inputs\",\"params\":[{\"name\":\"a\",\"value\":\"$(params.a)\"},{\"name\":\"b\",\"value\":\"$(params.b)\"}],\"taskRef\":{\"name\":\"sum-two-ints\"}},{\"name\":\"print-sum\",\"params\":[{\"name\":\"result\",\"value\":\"$(tasks.sum-inputs.results.sum-result)\"}],\"taskRef\":{\"name\":\"format-result\"}}]}}\n"
                },
                "creationTimestamp": "2020-05-27T17:13:57Z",
                "generation": 1,
                "labels": {
                    "tekton.dev/pipeline": "sum-and-print-pipeline"
                },
                "name": "sum-and-print-pipeline-run",
                "namespace": "default",
                "resourceVersion": "3865787",
                "selfLink": "/apis/tekton.dev/v1beta1/namespaces/default/pipelineruns/sum-and-print-pipeline-run",
                "uid": "a2d77a34-9853-46f7-9f00-45e1a76865e4"
            },
            "spec": {
                "params": [
                    {
                        "name": "a",
                        "value": "100"
                    },
                    {
                        "name": "b",
                        "value": "1000"
                    }
                ],
                "pipelineRef": {
                    "name": "sum-and-print-pipeline"
                },
                "timeout": "1h0m0s"
            },
            "status": {
                "completionTime": "2020-05-27T17:14:09Z",
                "conditions": [
                    {
                        "lastTransitionTime": "2020-05-27T17:14:09Z",
                        "message": "unable to find result referenced by param \"result\" in \"print-sum\": Could not find result with name sum-result for task run sum-inputs",
                        "reason": "InvalidTaskResultReference",
                        "status": "False",
                        "type": "Succeeded"
                    }
                ],
                "pipelineSpec": {
                    "params": [
                        {
                            "default": "1",
                            "name": "a",
                            "type": "string"
                        },
                        {
                            "default": "1",
                            "name": "b",
                            "type": "string"
                        }
                    ],
                    "tasks": [
                        {
                            "name": "sum-inputs",
                            "params": [
                                {
                                    "name": "a",
                                    "value": "$(params.a)"
                                },
                                {
                                    "name": "b",
                                    "value": "$(params.b)"
                                }
                            ],
                            "taskRef": {
                                "kind": "Task",
                                "name": "sum-two-ints"
                            }
                        },
                        {
                            "name": "print-sum",
                            "params": [
                                {
                                    "name": "result",
                                    "value": "$(tasks.sum-inputs.results.sum-result)"
                                }
                            ],
                            "taskRef": {
                                "kind": "Task",
                                "name": "format-result"
                            }
                        }
                    ]
                },
                "startTime": "2020-05-27T17:13:57Z",
                "taskRuns": {
                    "sum-and-print-pipeline-run-sum-inputs-5n2jl": {
                        "pipelineTaskName": "sum-inputs",
                        "status": {
                            "completionTime": "2020-05-27T17:14:09Z",
                            "conditions": [
                                {
                                    "lastTransitionTime": "2020-05-27T17:14:09Z",
                                    "message": "All Steps have completed executing",
                                    "reason": "Succeeded",
                                    "status": "True",
                                    "type": "Succeeded"
                                }
                            ],
                            "podName": "sum-and-print-pipeline-run-sum-inputs-fhcjx-pod-5jhvd",
                            "startTime": "2020-05-27T17:13:58Z",
                            "steps": [
                                {
                                    "container": "step-sum",
                                    "imageID": "docker-pullable://bash@sha256:145e00f05adb8b2fcf914380f2efeeb0efeda8b3fb4025b1118146311099933f",
                                    "name": "sum",
                                    "terminated": {
                                        "containerID": "docker://ea4f25e6741d19b39f6013c0fbb52a44450ebb22ba8569c26c64cf53acb7c8d5",
                                        "exitCode": 0,
                                        "finishedAt": "2020-05-27T17:14:08Z",
                                        "reason": "Completed",
                                        "startedAt": "2020-05-27T17:14:08Z"
                                    }
                                }
                            ],
                            "taskSpec": {
                                "params": [
                                    {
                                        "default": "1",
                                        "description": "The first integer",
                                        "name": "a",
                                        "type": "string"
                                    },
                                    {
                                        "default": "1",
                                        "description": "The second integer",
                                        "name": "b",
                                        "type": "string"
                                    }
                                ],
                                "results": [
                                    {
                                        "description": "The sum of the two provided integers",
                                        "name": "sum-result"
                                    }
                                ],
                                "steps": [
                                    {
                                        "image": "bash:latest",
                                        "name": "sum",
                                        "resources": {},
                                        "script": "#!/usr/bin/env bash\necho $(params.a)\necho $(params.b)\n"
                                    }
                                ]
                            }
                        }
                    }
                }
            }
        }
    ],
    "kind": "List",
    "metadata": {
        "resourceVersion": "",
        "selfLink": ""
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment