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,459,283
Community Members
 
Community Events
176
Community Groups

Re-use step with different variable

I have a step that executes a custom .NET tool to migrate a legacy database. It's designed to take a parameter representing the database to migrate so that you can call it like so:

dotnet run -- SC
dotnet run -- AL
dotnet run -- GA

Each run will migrate the specified database. I can set up a step to execute these three lines one after another in a single script within a single step but I'd like to be able to run them in parallel. So I have a boilerplate anchored step with all the pre-amble script that eventually culminates in

dotnet run -- ${STATE}

But now I'm having trouble figuring out how to arrange the parallel steps to pass in the contents of the ${STATE} variable to each instance of the step.

I've searched the forum and elsewhere and discovered it's not easy to do this. I found an open issue (that I've since lost) to allow sharing variables across steps. I also found one trick to save the variable you want as an artifact to be picked up by the later step but I'm not sure that will work because as far as I know, I'll just end up overwriting the same artifact used by the shared step for each iteration. So I'm wondering what's a good workaround that will let me execute many instances of this shared step, each with a different value for this one ${STATE} variable.

1 answer

1 accepted

0 votes
Answer accepted

Hey @kbaley 

You can try and wrap the step's script in a file and then pass the state as an argument to the script. Something like this:

- step:
   script:
      - ./my_script "SC"

- step:
   script:
      - ./my_script "AL"

Hope that helps

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events