I have the following deployments:
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.
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
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.