Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No variable substitution when using matrix and array the length of 1 #8157

Closed
zregvart opened this issue Jul 29, 2024 · 0 comments · Fixed by #8158
Closed

No variable substitution when using matrix and array the length of 1 #8157

zregvart opened this issue Jul 29, 2024 · 0 comments · Fixed by #8158
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@zregvart
Copy link
Contributor

Expected Behavior

Variable substitution occurs regardless of the length of the array parameter. Example:

tkn pipeline start -f pipeline.yaml --showlog    
PipelineRun started: matrix-vars-run-6jd5z
Waiting for logs to be available...
[produce : set-var] cat

[use-vars : use-vars] cat

Actual Behavior

The variable expression is printed when the array has a length of 1. Example:

$ tkn pipeline start -f pipeline.yaml --showlog    
PipelineRun started: matrix-vars-run-6jd5z
Waiting for logs to be available...
[produce : set-var] cat

[use-vars : use-vars] $(tasks.produce.results.vars[*])

Steps to Reproduce the Problem

  1. Create a file pipeline.yaml with content:
pipeline.yaml
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: matrix-vars
spec:
  tasks:
    - name: produce
      matrix:
        params:
          - name: var
            value:
              - cat
              # - dog
              # - squirrel
      taskSpec:
        params:
          - name: var
            type: string
        results:
          - name: vars
            type: string
        steps:
          - name: set-var
            image: alpine
            script:
              echo -n $(params.var) | tee $(results.vars.path)
    - name: use-vars
      params:
        - name: vars
          value:
            - $(tasks.produce.results.vars[*])
      taskSpec:
        params:
          - name: vars
            type: array
        steps:
          - name: use-vars
            image: alpine
            args: ["$(params.vars[*])"]
            script:
              echo $*
	
  1. Run tkn pipeline start -f pipeline.yaml --showlog
  2. Examine the output to see:
PipelineRun started: matrix-vars-run-dt42r
Waiting for logs to be available...
[produce : set-var] cat

[use-vars : use-vars] $(tasks.produce.results.vars[*])
  1. Uncomment any values of the produce.matrix.params["var"].values, so the length of the vars result from the produce Task is influenced, and notice that the expression is not printed but values from the result

Additional Info

  • Kubernetes version:

    Output of kubectl version:

Client Version: v1.25.3
Kustomize Version: v4.5.7
Server Version: v1.30.0
  • Tekton Pipeline version:

    Output of tkn version or kubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'

Client version: 0.37.0
Pipeline version: v0.62.0
@zregvart zregvart added the kind/bug Categorizes issue or PR as related to a bug. label Jul 29, 2024
zregvart added a commit to zregvart/pipeline that referenced this issue Jul 29, 2024
Given a matrix run of a TaskRun with cardinality of 1, the result from
it will not be converted to an array but kept as a string, i.e. as if
the TaskRun was not configured to run with matrix.

This causes issues for consumers of the TaskRun's results as they will
be configured to consume array results. As a result making the passed
value equal to expression value instead.

Resolves: tektoncd#8157
tekton-robot pushed a commit to tekton-robot/pipeline that referenced this issue Jul 31, 2024
Given a matrix run of a TaskRun with cardinality of 1, the result from
it will not be converted to an array but kept as a string, i.e. as if
the TaskRun was not configured to run with matrix.

This causes issues for consumers of the TaskRun's results as they will
be configured to consume array results. As a result making the passed
value equal to expression value instead.

Resolves: tektoncd#8157
tekton-robot pushed a commit to tekton-robot/pipeline that referenced this issue Jul 31, 2024
Given a matrix run of a TaskRun with cardinality of 1, the result from
it will not be converted to an array but kept as a string, i.e. as if
the TaskRun was not configured to run with matrix.

This causes issues for consumers of the TaskRun's results as they will
be configured to consume array results. As a result making the passed
value equal to expression value instead.

Resolves: tektoncd#8157
tekton-robot pushed a commit to tekton-robot/pipeline that referenced this issue Jul 31, 2024
Given a matrix run of a TaskRun with cardinality of 1, the result from
it will not be converted to an array but kept as a string, i.e. as if
the TaskRun was not configured to run with matrix.

This causes issues for consumers of the TaskRun's results as they will
be configured to consume array results. As a result making the passed
value equal to expression value instead.

Resolves: tektoncd#8157
tekton-robot pushed a commit that referenced this issue Jul 31, 2024
Given a matrix run of a TaskRun with cardinality of 1, the result from
it will not be converted to an array but kept as a string, i.e. as if
the TaskRun was not configured to run with matrix.

This causes issues for consumers of the TaskRun's results as they will
be configured to consume array results. As a result making the passed
value equal to expression value instead.

Resolves: #8157
tekton-robot pushed a commit that referenced this issue Jul 31, 2024
Given a matrix run of a TaskRun with cardinality of 1, the result from
it will not be converted to an array but kept as a string, i.e. as if
the TaskRun was not configured to run with matrix.

This causes issues for consumers of the TaskRun's results as they will
be configured to consume array results. As a result making the passed
value equal to expression value instead.

Resolves: #8157
tekton-robot pushed a commit that referenced this issue Aug 1, 2024
Given a matrix run of a TaskRun with cardinality of 1, the result from
it will not be converted to an array but kept as a string, i.e. as if
the TaskRun was not configured to run with matrix.

This causes issues for consumers of the TaskRun's results as they will
be configured to consume array results. As a result making the passed
value equal to expression value instead.

Resolves: #8157
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant