David Lartey
David Lartey

Reputation: 579

How to keep Bitbucket Pipeline from deploying branch

I have a master and a dev branch, I push every commit to both. I run my tests once more on both in a Pipeline. However, I don't want to deploy both, I only need the master branch to be deployed.

What happens currently is, the second branch to get through to the deployment step will be paused. It's the same code currently but that might not be the case always. I will like to know if there is a way to achieve a similar setup.

pipelines:
  default:
    -step:
       name: My Test Step
       # ...
    -step
       name: Deployment Step
       # ....

This is how my bitbucket-pipelines.yml file is currently structured.

Upvotes: 1

Views: 1937

Answers (2)

Bayu Dwiyan Satria
Bayu Dwiyan Satria

Reputation: 1058

You need to specify your your pipelines trigger on bitbucket-pipelines.yml

Reference : https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/

Examples :

definitions: 
  
  steps:
  
    # Build
    - step: &build
        name: Install and Test
        ....

     # Deployment
     - step: &deploy
        name: Deploy Artifacts
        trigger: automatic
        deployment: test
        ....


# Runner
pipelines:

  # Running by tags
  tags:
    v*:
      - step: *build
      - step: 
          <<: *deploy
          deployment: test
          trigger: manual

  # Running by branch
  branches:

    master:
      - step: *build
      - step:
          <<: *deploy
          deployment: staging
          trigger: manual
    
    develop:
      - step: *build
      - step:
          <<: *deploy
          deployment: test
          trigger: automatic

Upvotes: 1

floflock
floflock

Reputation: 635

This config do you need. This pipline runs only on master commits.

pipelines:    
    branches:
        master:
          - step:
              name: Clone
              script:
                - .... 

Upvotes: 2

Related Questions