Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitbucket Pipelines share SOME steps between branches

Is it possible to share steps between branches and still run branch specific steps? For example, the develop and release branch has the same build process, but uploaded to separate S3 buckets.

pipelines:   default:     - step:         script:           - cd source           - npm install           - npm build   develop:     - step:         script:           - s3cmd put --config s3cmd.cfg ./build s3://develop    staging:     - step:         script:           - s3cmd put --config s3cmd.cfg ./build s3://staging 

I saw this post (Bitbucket Pipelines - multiple branches with same steps) but it's for the same steps.

like image 573
YarGnawh Avatar asked Aug 08 '17 02:08

YarGnawh


1 Answers

Use YAML anchors:

definitions:   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         name: Deploy to production         deployment: production         trigger: manual 

Docs: https://confluence.atlassian.com/bitbucket/yaml-anchors-960154027.html

like image 75
Max Malysh Avatar answered Oct 04 '22 05:10

Max Malysh