Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid Using Master Branch for BitBucket Pipeline

I'm setting up a CI pipeline on a BitBucket Repository based around docker. I'm running build commands then up then test, basically. This all works so far, but the issue I'm having is BitBucket only commits or lets me edit changes to the bitbucket-pipelines.yaml file on the master branch.

I'm not the only developer on the project, and right now our master is our staging/ready for prod branch, and we've all agreed to use other branches for things and let one of us manage master and merges into it.

My question is, can I use another, different branch than master to "manage" my pipelines file on, like our active development branch? For some reason, I can't find a way to add a pipeline to another branch, and pushing up a bitbucket-pipelines.yaml file on the develop branch won't trigger a build.

For reference, my pipeline yaml:

image: atlassian/default-image:2

pipelines:
  # pull-requests:
  #   'feature/*':
  #     - step:
  #       services:
  #         - docker
  branches:
    develop:
      # each step starts a new Docker container with a clone of your repository
      - step:
        services:
          - docker
        script:
          - (cd app/laravel/ ; npm install)
          - (cd app/laravel/ ; npm run production)
          - docker build -t myApp -f app/Dockerfile app/
          - docker stack up -c docker/docker-compose.yaml myApp
like image 215
RoboBear Avatar asked Mar 03 '23 09:03

RoboBear


1 Answers

You should be able to have a pipeline in any branch you want.
From the troubleshooting section:

My branch doesn't build

Make sure that there is a bitbucket-pipelines.yml file in the root of your branch.

To build a branch, you must specify a default or a branch-specific pipeline configuration.
For more information, see Configure bitbucket-pipelines.yml.

I would test that, following branch workflow, with a simplified yaml first (one which does just an echo for a given branch), for testing.

As the OP RoboBear confirms in the comments, the bitbucket-pipelines.yml must use the .yml extension, not .yaml.

like image 98
VonC Avatar answered Mar 05 '23 16:03

VonC