Long lived and Short lived branches query in SonarQube

2.4k Views Asked by At

I have a query with SonaQube analyzing for long lived and short lived branches. Suppose if I have branches main,release,master,feature branches in my azurerepos. I am doing a sonar amaysis on the source code...now if I have created some pull request to merge feature branch to master which has sonar analysis task step in it and haven't yet merged the PR to master branch. Now in SonarUI will the analysis shows for the PR? or the analysis will show only if I merge the PR to master branch? and will sonar UI display all the branches which have sonaranalysis step in the pipeline? or is there any limitation for long lived and short lived branches display in SonarUI? Asking for snarQube 8.0 and 8.5 version

2

There are 2 best solutions below

4
On BEST ANSWER

Check documentation here:

https://docs.sonarqube.org/latest/analysis/pull-request/

You can see your Pull Requests in SonarQube from the Branches and Pull Requests dropdown menu of your project.

Pull Request analysis shows your Pull Request's Quality Gate and analysis in the SonarQube interface.

Before analyzing your Pull Requests, make sure the Pull Request branch is checked out. Avoid any attempt at previewing the merge or actions involving your main branch.

Which branch you want to analyze, check out which branch in your pipeline. There is a video that shows how SonarQube analyzes Pull Requests:

https://www.sonarqube.org/microsoft-azure-devops-integration/

0
On

One misconception that I often see is that people think that Sonarqube "actively" scans codebases. SonarQube mostly just sits there and waits for you to ask it to do something. The responsibility for running a scan belongs to your build automation. SonarQube doesn't know when you create feature branches or merge them to target branches. If you want a scan of your feature branch (which I definitely recommend), you have to implement automation between your central git repository and your build system (Jenkins, most likely) that makes that happen.