Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I re-use steps with slight variations in the scripts between pipelines? Edited

I have defined a step to build and test .NET code that I want to re-use in multiple pipelines:

step: &prepare
- dotnet build --configuration Debug
- dotnet test --configuration Debug --no-build

- step: *prepare
- step: *prepare

When the pipeline for the `master` branch is run, I need to pass `--configuration Release` instead of `--configuration Debug`, so that the artifacts are optimized.

How can I re-use this `prepare` step with a slight variation in the scripts between pipelines? Can I declare variables per pipeline and refer to them in the scripts?

I tried to use a `variables` section as part of the pipeline, but that is not allowed for pipelines targeting `pull-requests` or `branches`. It is only allowed for custom pipelines.


I know I can use YAML's ability to merge, but that only allows me to customize pre-defined step properties per pipeline, such as `trigger` or `environment`. Although powerful, this does not help in this scenario, where the customization is required at the level of an individual script.

One work-around is to use Bash scripting to inspect the current branch, and derive the correct values for the command-line options from that. But I'd rather use a declarative solution, since that is easier to write and easier understand.

Another work-around is to declare the step to be a deployment step, and then start using deployment variables. But I think most would agree that build and test is not deployment, so declaring the step as a deployment step is indeed a work-around.


1 answer

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

504 views 6 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you