11

Sonarqube Server Version 7.0 (build 36138)

Sonarqube Branch Plugin 7.0 (build 413)

sonar-maven-plugin:3.4.0.905

Java project

Sonarqube is set up with a master branch already.

As part of a Jenkins build job we execute the following command:

mvn sonar:sonar -Dsonar.host.url=<our host> -Dsonar.projectName=<project name> -Dsonar.projectKey=<project name> -Dsonar.branch.name=${BRANCH}

where BRANCH is set to the branch name we are building in Jenkins.

Analysis appears to work when we build our "develop" branch in that the develop branch appears if it isn't in Sonarqube and the timestamp for the analysis is correct on the server, but there are two issues:

1) I've set "develop" to be a long-lived branch per the instructions in https://docs.sonarqube.org/display/PLUG/Branch+Plugin by modifying the long-lived branch regex in the SQ server to be:

(branch|release|develop)-.*

but I only see the Issues and Code tabs on the "develop" branch display. And in the Jenkins job, I see the message:

[INFO] Branch name: develop, type: short living

which leads me to believe that develop is not being recognized as a long living branch.

2) There is no output in the Issues tab. Only the code tab shows anything. But the master branch output shows 225 issues, so I would expect the same list of issues in the develop branch (since they haven't been addressed).

Questions:

  1. Do long living branches show all of the same output that you normally see for the master branch, including "Overview"?

  2. Is there something that I need to do to specify the "develop" branch as long-living in the maven command above?

  3. Any idea why the issues tab doesn't show anything?

Many thanks, Wes

Wes Gamble
  • 777
  • 10
  • 29

2 Answers2

5

In my opinion it is your regex you should check first. You are using the default (branch|release|develop)-.* notice that you have added hyphen(-) at the end.
So, sonar expects the branch name to be branch-, release- or develop-. In your case I believe the regex should be (branch|release|develop).*

Aman
  • 1,627
  • 13
  • 19
  • 1
    You saved me! My hero... I didn't even see the - and don't know why that's the default. – wheeleruniverse Sep 04 '20 at 20:22
  • Glad that it helped @jDub9 – Aman Sep 06 '20 at 15:14
  • @Aman where is the convention for sonar branch defined, in my case my pull request branch name coventions are PR-.* but I still see sonar didn't scan and failed. – vgdub May 25 '21 at 12:52
  • @vgdub you should find it under the menu *Branches* -> *Detection of Long lived branches*. – Aman May 25 '21 at 13:40
  • Got it , in my use case sonar isn't able to pick the branch for short lived PR (pull request ones) properly , my regex has additional PR-* , but it fails to scan, – vgdub May 25 '21 at 13:48
  • what do you mean by *isn't able to pick?*, sonar favors long lived once. you can check how short lived once are managed here https://docs.sonarqube.org/7.4/branches/short-lived-branches/ – Aman May 25 '21 at 14:04
  • what I mean by that was in my setup of Bitbucket server (branch source plugin) --> Jenkins MultiBranch pipeline which uses PR only revision + Sonar Scanner job , didn't do the scan of my Pull Request and the reason I digged into was it doesn't see the merge commit , see here https://community.sonarsource.com/t/sonar-scanner-for-pull-request-failing-with-jenkins-multibranch-and-bitbucket-server/44259 – vgdub Jun 07 '21 at 10:56
  • Very strange, indeed PR-353 is short living. can you share the regex? – Aman Jun 07 '21 at 11:21