How to trigger PR pipelines in CircleCI for BitBucket

Hey folks,

I couldn’t find a way to trigger a CircleCI build when a pull request was opened or updated in BitBucket. I only found a thread where people were discussing this issue but with no solution available (

As the thread is already closed, I am posting my solution here! It is quite simple once you come up with the “hack”: Simply use the BitBucket PR pipeline for triggering a new build in CircleCI

Here is my bitbucket-pipelines.yml file:

      - step:
          name: Trigger PR workflow on CircleCI
            - echo "Triggering PR build for branch $BITBUCKET_BRANCH"
            - >
              curl -ss -X POST -H "Content-Type: application/json" -d '{"build_parameters":{"BITBUCKET_PR":true}}' "$BITBUCKET_BRANCH?circle-token=$CIRCLE_CI_ACCESS_TOKEN"

Note: I could not use a CircleCI 2.1 config as the API does not support “build_parameters” yet (see the API doc: Therefore, I needed to downgrade to version 2.0 so I could set a “PR” environment variable when triggering the build.

This “hack” only costs you around 4-6 seconds in BitBucket pipelines as the job is triggered and thats it so the pipeline finishes quite quickly.

Hope this helps out some people :slight_smile:

Best regards,



Thanks for your solution. Do you have any idea how to escape a branchname if is has an “/” in it?