You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.