Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitbucket Pipelines - multiple branches with same steps

Is it possible to combine multiple branches that have the same steps within bitbucket pipelines?

ex: The teams I work on use one of two names for their review branches, either "rev" or "staging". Either way the same steps are used to publish to our review server. Right now the branches are called out separately.

pipelines:      branches:           rev:                steps:                     - echo 'step'           staging:                steps:                     - echo 'step' 

but could it be something like

pipelines:      branches:           rev|staging:                steps:                     - echo 'step' 
like image 819
Gery Teague Avatar asked Feb 17 '17 17:02

Gery Teague


People also ask

What is parallel in Bitbucket pipeline?

Parallel steps enable you to build and test faster, by running a set of self-contained steps at the same time.

How does Bitbucket pipeline work?

Bitbucket Pipelines is an integrated CI/CD service built into Bitbucket. It allows you to automatically build, test, and even deploy your code based on a configuration file in your repository. Essentially, we create containers in the cloud for you.

How do I set an environment variable in Bitbucket pipelines?

In Bitbucket, go to the repository you want to scan and select Settings > Pipelines > Environment variables. Verify the Secured checkbox is selected. Click Add.


2 Answers

A comma-separated list inside braces appears to work:

pipelines:   branches:     '{rev,staging}':       - step:         script:           - echo 'step' 
like image 172
RH Becker Avatar answered Sep 24 '22 05:09

RH Becker


This is a full example on how you can reuse some steps:

image: yourimage:latest  definitions:   services: ... # Service definitions go there   steps:     - step: &Test-step         name: Run tests         script:           - npm install           - npm run test     - step: &Deploy-step         name: Deploy to staging         deployment: staging         script:           - npm install           - npm run build           - fab deploy pipelines:   default:     - step: *Test-step     - step: *Deploy-step   branches:       master:         - step: *Test-step         - step:             <<: *Deploy-step             deployment: production             trigger: manual 

Read more about YAML anchors: https://confluence.atlassian.com/bitbucket/yaml-anchors-960154027.html

like image 35
Max Malysh Avatar answered Sep 23 '22 05:09

Max Malysh