Pull request trigger build on BitBucket


I’m currently testing the Sonarcloud integration with BitBucket and it is working fine, except for the pull request analysis. Here is my YML:

image: atlassian/default-image:2

  depth: full             

    sonar: ~/.sonar/cache  
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
          - sonar
          - pipe: sonarsource/sonarcloud-scan:1.2.0
              SONAR_TOKEN: ${SONAR_TOKEN}
              EXTRA_ARGS: '-Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="**/testing/**,**/*.spec.ts" -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info -Dsonar.test.exclusions="git/**, sonarqube/**, vendor/**"'
    - step: *build-test-sonarcloud
      - step: *build-test-sonarcloud

It works fine when I accept the pull request or when I manually run the pipeline.
But it never triggers to analyze the pull request itself.

What am I missing here?

Any help is much appreciated, thank you.

Welcome to the community!

I’m not sure I understand the issue, I have a few clarification questions:

  • Do you mean that when you create a pull request, the pipeline is not triggered? (That would be a functionality of Bitbucket Cloud.)
  • When you say that “It works fine when I accept the pull request”, do you mean that when the pull request is merged into the main branch, the pipeline triggers as expected? Or something else?
1 Like

Thank you :slight_smile:

Yes, if I understand it correctly it should trigger the pipeline when the pull request is created. Right?
I’m using Bitbucket Cloud.

Also yes, that’s what I meant.

I clicked solved by mistake (already unclicked it). Still can’t run it properly.

I finally got it working. The problem wasn’t the YML or anything with the code. I found this snipped from the BitBucket pipeline triggers documentation:

pull-request: A special pipeline that only runs on pull requests initiated from within your repo. It merges the destination branch into your working branch before it runs. Pull requests from a forked repository don’t trigger the pipeline

It only works when the pull request is created from the same repo, not the forked one.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.