In my bitbucket pipeline, in multiple steps and scripts, I want to loop through a common list of strings.
Azure Pipelines shows an example of how to do this in the "Loop through parameters section": https://docs.microsoft.com/en-us/azure/devops/pipelines/process/runtime-parameters?view=azure-devops&tabs=script
However this syntax is not valid according to the bitbucket-pipelines.yml validator tool: https://bitbucket-pipelines.atlassian.io/validator
How can I do this in Bitbucket Pipelines?
Bonus points if I can do this within a script, as opposed to at the step level.
An example of what I would like to do:
parameters:
- name: myList
type: object
default:
- listString1
- listString2
pipelines:
default:
- step:
- ${{ each exampleString in parameters.myList }}:
- script: echo ${{ exampleString }}
I found a similar concept here: https://community.atlassian.com/t5/Bitbucket-questions/Array-value-on-Environment-Variables-for-BitBucket-Pipelines/qaq-p/875894
It uses repository or workspace pipeline variables as an array, which you can then loop through in your bitbucket-pipeline.yml. So this technically works as a solution.
However, I'd have preferred a way to do this inside the yml file as opposed to in Bitbucket settings, since now those variables are not tracked in git, although they can be visible in pipeline logs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.