Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,833
Community Members
 
Community Events
176
Community Groups

Pipelines - Use list to loop in multiple scripts/steps

Edited

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 }}

1 answer

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.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS

Atlassian Community Events