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

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

Some branches have shared steps & first step cannot be manual

I have the following deployments:

  • Test
  • Security
  • Staging
  • Production

I have steps associated with each deployment.  Each deployment has deployment variables associated with it.

I would like to run the "Test" & "Security" steps on all branches.  I would like the "develop" branch to run the steps for "Test", "Security" & "Staging".  I would like the "master" branch to run the steps for "Test", "Security", "Staging", and "Production".  Any other branches like "feature/*" only run steps for "Test" & "Security".  

The "Production" steps have a manual trigger.

I tried doing a combination of default: and branches:, but it looks like default: only runs on NON-MATCHED branches.  

 

Any suggestions will be greatly appreciated.

 

1 answer

0 votes

Hi @Monica Gordillo ,

Since you want to reuse the same steps for different branches, I would suggest using YAML anchors to define these steps.

You can check the following doc for more information on YAML anchors:

Based on the description of your deployments and also which deployments you want to run for a specific branch, I believe you could structure your bitbucket-pipelines.yml file as follows:

definitions: 
steps:
- step: &test
name: Test
deployment: Test
script:
- echo "Test deployment"
- step: &security
name: Security
deployment: Security
script:
- echo "Security deployment"
- step: &staging
name: Staging
deployment: Staging
script:
- echo "Staging deployment"
- step: &production
name: Production
deployment: Production
trigger: manual
script:
- echo "Production deployment"

pipelines:
default:
- step: *test
- step: *security
branches:
develop:
- step: *test
- step: *security
- step: *staging
master:
- step: *test
- step: *security
- step: *staging
- step: *production

The section with the keyword definitions defines each deployment step as an anchor, so you can reuse it later.
Then, the pipelines section defines which steps to run depending on the branch.

Is this something that works for you?

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

528 views 15 17
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