How to enable automatic Pull Request detection

  • SonarQube Enterprise, Azure Devops, GitHub
  • Trying to enable PR detection and decoration

According to the documentation here, SonarQube can now automatically detect branches and Pull Requests. So far, the branch detection works just fine, but not the PR detection.

We are using Azure Pipelines to run our builds, and the SonarQubePrepare@4, SonarQubeAnalyze@4, and SonarQubePublish@4 tasks to communicate with our SonarQube server. The branch detection works perfectly: each new branch that builds creates a corresponding branch in SonarQube, and the Quality Gates work to pass or fail the code on the new branch.

However, even after a Pull Request is created in GitHub, and the pipeline is restarted, SonarQube does not detect the PR and perform the necessary decoration. If we look on the Project Settings -> Branches & Pull Requests page, the Pull Requests tab is always empty.

So far we have tried visiting the Administration -> ALM Integrations page, and added configurations for GitHub and Azure Devops. On each project we have visited Project Settings -> General Settings page and filled in the configuration of Pull Request Decoration. What is the missing piece to the puzzle?

Hi @OldManLink,

As you can read in the documentation you mentioned, PR auto-detection is available when running the scanner within Github Actions. Same goes for Azure Pipelines, PR auto-detection is available for repositories and PR opened in Azure DevOps.

If I understood your case properly, you’re running Azure Pipelines against a Github repository, which therefore isn’t supported out of the box.

I see 2 steps to make it work from here:

  1. Make sure your project pull request decoration is correctly bind to the Github instance you declared in Administration > ALM Settings.
  2. Make the scanner that is running in Azure Pipelines gets the necessary information to be able to decorate the PR.

Regarding point #2, I am honestly not sure it is achievable. I’d advise you to have look at your integration between your Github repository and your Azure Pipelines, and see if your pipeline trigger (on the Github side) is capable of providing those information to the scanner (on the Azure Pipelines side).

I hope it was clear, let me know if not.

1 Like

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

FYI we’ll be soon working on helping users who, like you, are using Azure Pipelines with a Github repository.