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

If I want extra steps to run on master, do I have to define the default steps twice?

Chris Doman March 17, 2021

I see in the Bitbucket pipelines documentation that I can specify steps to run just on master, i.e.

branches:

    master:

 

I want the steps in default: to run as well as the specific ones for master:

- Do I need to define those twice?

i.e. Do I need to do this, or is there a more efficient way?

 



pipelines:
default:
- step:
name: Step one
script:
- echo Step One Is Identical Both Times
branches:
master:
- step:
name: Step one
script:
- echo Step One Is Identical Both Times
- step:
name: Step two
script:
- echo Step two

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 19, 2021

Hi @Chris Doman ,

You can use YAML anchors for repeated sections, to make the file easier to read and also update:

E.g. the example you included would look like this with anchors:

definitions:
steps:
- step: &step-one
name: Step one
script:
- echo Step One Is Identical Both Times

pipelines:
default:
- step: *step-one
branches:
master:
- step: *step-one
- step:
name: Step two
script:
- echo Step two

Is this something that works for you? Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Chris Doman March 19, 2021

Thats great - Thankyou Theodora

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events