Open EmmaMunley opened 1 year ago
cc: @jerop, @lbernick, @pritidesai, @Yongxuanzhang
Thanks! This is the same as https://github.com/tektoncd/pipeline/issues/4912
given that the same issue has come up again, can we please document this as a known limitation? 🙏🏾
Indeed, this was never supported, as it is not obvious what the representation of the array should be, especially since it's now known in which environment it will be used.
We do support indexing in arrays now, which is a step forward.
If we supported something like $(#params.TEST[*])
to read the length of the array, it would be possible for scripts to iterate on element arrays.
If users want to iterate the array params in script, this can do this:
taskSpec:
params:
- name: environments
type: array
steps:
- name: use-environments
image: bash:latest
args: [
"$(params.environments[*])",
]
script: |
for arg in "$@"; do
echo "Arg: $arg"
done
So even if we cannot use the whole array ref in script directly, we have the workaround to pass the array params to args and reference it in script
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close
with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen
with a justification.
/lifecycle stale
Send feedback to tektoncd/plumbing.
Expected Behavior
I expect to be able to run this yaml file and have it echo the array values.
Actual Behavior
Instead I get this error message:
Error from server (BadRequest): error when creating "test.yaml": admission webhook "validation.webhook.pipeline.tekton.dev" denied the request: validation failed: variable type invalid in "echo \"$(params.TEST[*])\"\n": spec.steps[0].script
As a workaround, you can use environment variables like so, but this doesn't always work because I sometimes get this error:
env: can't execute 'bash': No such file or directory
Steps to Reproduce the Problem
Additional Info
Kubernetes version:
Output of
kubectl version
:Tekton Pipeline version:
Output of
tkn version
orkubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'