You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.
Join groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
I have defined a step to build and test .NET code that I want to re-use in multiple pipelines:
definitions:
steps:
step: &prepare
name:
script:
- dotnet build --configuration Debug
- dotnet test --configuration Debug --no-build
pipelines:
pull-requests:
feature/*:
- step: *prepare
branches:
master:
- 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.
P.S.
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.
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...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.