God! Before you also go and break your head, confused with how to do this, you can take help from my experience.

I was trying to integrate pronto (automatic code analyser) with bitbucket CI. I had done this earlier with gitlab and github so I thought it'll be a piece of cake but God was I wrong.

First of all there is no good documentation, there is no decent blog post as well to help out.

So I had configured the pipeline like below:

image: absk1317/ruby-node-pg:2.6

pipelines:
  default:
    - parallel:
      - step:
          name: Test
          caches:
            - bundler
          script:
            - cp .env.example .env
            - export DATABASE_URL=postgresql://postgres:root@localhost/test
            - bundle install -j 4 --path vendor
            - bundle exec rake db:migrate --trace RAILS_ENV=test
            - bundle exec rspec
          services:
            - postgres
      - step:
          name: Lint
          caches:
            - bundler
          script:
            - bundle install --path vendor
            - bundle exec pronto run -f bitbucket_pr -c origin/master

definitions:
  caches:
    bundler: ./vendor
  services:
    postgres:
      image: postgres:9.5
      environment:
        POSTGRES_DB: test
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: root

Everything felt alright, but there was something wrong.

Bitbucket runner was not able to find origin/master while doing the comparison.

I tried debugging it in n number of ways. Tried printing the remote, tried looking up for proper permissions, for proper directories, for what not.

Lastly, after struggling for nearly two hours, I tried listing all the branches available there during the pipeline, and voila, only the current branch was there. There wasn't any master or any other branch.

Now how do I solve this? I started reading through entire documentation of Bitbucket CI. There somewhere I read that the runners do kind of a shallow clone of the repo (most recent 50 commits) in order to keep it concise.
So I tried adding

clone:
  depth: full

in the very start of the config, and voila, now everything works!
The entire content of the file are:

image: absk1317/ruby-node-pg:2.6
clone:
  depth: full
  
pipelines:
  default:
    - parallel:
      - step:
          name: Test
          caches:
            - bundler
          script:
            - cp .env.example .env
            - export DATABASE_URL=postgresql://postgres:root@localhost/test
            - bundle install -j 4 --path vendor
            - bundle exec rake db:migrate --trace RAILS_ENV=test
            - bundle exec rspec
          services:
            - postgres
      - step:
          name: Lint
          caches:
            - bundler
          script:
            - bundle install --path vendor
            - bundle exec pronto run -f bitbucket_pr -c origin/master

definitions:
  caches:
    bundler: ./vendor
  services:
    postgres:
      image: postgres:9.5
      environment:
        POSTGRES_DB: test
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: root

Happy testing!