tektoncd / pipeline

A cloud-native Pipeline resource.
https://tekton.dev
Apache License 2.0
8.37k stars 1.76k forks source link

Task results variable substitution is broken #7852

Open tomalexander opened 3 months ago

tomalexander commented 3 months ago

Expected Behavior

The "echo-variable" task in the example PipelineRun should print to stdout "The variable: dolar"

Actual Behavior

The "echo-variable" task in the example PipelineRun prints:

2024-04-07T01:25:23.656135143Z /tekton/scripts/script-0-8b297: line 2: tasks.set-variable.results.ipsum: not found
2024-04-07T01:25:23.656332139Z The variable: 

Steps to Reproduce the Problem

Broken:

Install the tekton operator helm chart from this commit: https://github.com/tektoncd/operator/commit/7bc7f7eb4a5b327a9c66929c6a89974fab85de75

(note: that is just the latest commit, I am not blaming that commit specifically)

Then kubectl apply this PipelineRun: (note, you may need to change the namespace based on your tekton setup)

apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  name: minimal-test
  namespace: lighthouse
spec:
  pipelineSpec:
    tasks:
      - name: echo-variable
        taskSpec:
          metadata: {}
          stepTemplate:
            image: alpine:3.18
            name: ""
            resources:
              requests:
                cpu: 10m
                memory: 600Mi
          steps:
            - image: alpine:3.18
              script: |
                #!/usr/bin/env sh
                echo "The variable: $(params.LOREM)"
        params:
          - name: LOREM
            value: $(tasks.set-variable.results.ipsum)
      - name: set-variable
        taskSpec:
          metadata: {}
          stepTemplate:
            image: alpine:3.18
            name: ""
            resources:
              requests:
                cpu: 10m
                memory: 600Mi
          results:
            - name: ipsum
          steps:
            - image: alpine:3.18
              script: |
                #!/usr/bin/env sh
                echo -n "dolar" > "$(results.ipsum.path)"
  timeout: 240h0m0s

Look at the output for the "echo-variable" step and see the error.

Working:

Do the exact same steps, except when installing tekton, install from this tag: https://github.com/tektoncd/operator/tree/tekton-operator-0.67.0

Additional Info

Client Version: v1.29.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.2
WARNING: version difference between client (1.29) and server (1.27) exceeds the supported minor version skew of +/-1

Broken

v0.50.1

Working

v0.47.0
l-qing commented 3 months ago

I see this issue can no longer be reproduced on the latest v0.58. Maybe you can try updating to the latest version and see if that helps?