Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I pass predefined variables as a list to a step in a Bitbucket pipeline?

Supul Pushpakumara
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 18, 2025

I have defined a reusable step in my Bitbucket pipeline that runs a script for different IMAGE_NAME values. Currently, I pass the IMAGE_NAME one by one in the script section for each step. Is there a way to pass all the IMAGE_NAME values together to a single step, or iterate over them without overriding the variables section for each step?


Details:

  1. Current Setup:

    • A reusable step is defined with a variables section that includes common variable.
    • The step is reused multiple times, each time with a different variable value.
  2. Goal:

    • Simplify the pipeline by passing all common variable values together to a single step.
    • Avoid duplicating the step for each common variable.
  3. Challenges:

    • The variables section in Bitbucket pipelines is static and cannot be dynamically overridden within a single step.
    • Iterating over a list of values within a single step is not natively supported in Bitbucket pipelines.

1 answer

0 votes
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 21, 2025

G'day, @Supul Pushpakumara 

Welcome to the community!

I believe what you are looking for can be achieved through the use of dynamic pipelines.

Dynamic pipelines provide significant flexibility to traditionally static YAML pipeline configurations by allowing runtime modifications through application-level logic. One key feature they offer is the ability to utilize environment, repository, or workspace variables to define Docker image names for use in CI/CD workflows. This capability enables you to dynamically modify each step of the pipeline as needed.

I hope this helps.

Regards,
Syahrul

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events