7

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
RoboBear
  • 5,434
  • 2
  • 33
  • 40

2 Answers2

6

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I'm embarrassed, it was the stupidest of mistakes. *.yml* with no 'a', otherwise it's not recognized. Thank you so much! *facepalm* – RoboBear Jun 03 '20 at 08:43
  • Now I can push any branch with a pipelines yml file and it will register and run as expected. – RoboBear Jun 03 '20 at 08:44
  • @RoboBear Thank you for this feedback. I have included your comment in the answer for more visibility. – VonC Jun 03 '20 at 08:49
6

My problem was that pipelines had not been enabled for the repo and since I added the bitbucket-pipelines.yml file to a branch that was not the main branch, and not using the onboarding tutorial, pipelines had not been enabled for the repository. Go to Repository settings -> Pipelines | Settings -> Enable Pipelines. Then you will have to push another change to the branch with the bitbucket-pipelines.yml and it should run the pipeline.

Victor
  • 3,395
  • 1
  • 23
  • 26