We’re using SonarQube Developer Edition 8.4.1 and SonarScanner 4.3.0.2102.
I’ve tried to change the “New Code” Analysis to point to reference Branch “Develop” (main branch) like documented here: https://docs.sonarqube.org/latest/project-administration/new-code-period/
When an analysis for a Feature Branch is performed, I see the following Error
“The scanner failed to compute New Code. Please check your scanner logs.”
Nevertheless there are no errors in the logs. It only shows up 2020.09.07 23:16:33 INFO ce[AXRq21OECwyxeiLQxQrS][o.s.c.t.s.ComputationStepExecutor] Compute new coverage | status=SUCCESS | time=73ms
“Develop” Branch was configured to use “previous analysis” for new code so there is no error.
Please check your scanner logs with debug enabled. If you post them, we can also have a look at it.
Most likely, for some reason, the scanner can’t compute the diff between the branch being analyzed and the reference branch using a SCM (git usually).
2020.09.09 07:35:38 DEBUG ce[AXRxyoSiGH0ILt3Vk4q0][o.s.c.t.p.p.NewCodePeriodResolver] Resolving new code period by previous version: 8.0.0-SNAPSHOT 2020.09.09 07:35:38 INFO ce[AXRxyoSiGH0ILt3Vk4q0][o.s.c.t.s.ComputationStepExecutor] Load new code period | status=SUCCESS | time=44ms
What irritates is the Message “This branch is configured to use itself as reference branch” which is (as you can see in the screens above) not correct.
UPDATE:
I just had a look at the scanner logs (not the sonarqube_ce.log as above) and found the following error: [2020-09-09T09:25:42.851Z] INFO: Computing New Code since fork with 'develop' [2020-09-09T09:25:42.851Z] WARN: Failed to detect fork date. No New Code will be computed.
Seems that the problem occurs with the SonarQube Scanner and not with SonarQube.
I use Jenkins Multibranch Pipelines to run SonarQube Scanner, which only retrieves the affected branch, so maybe this is the problem.
As far as “edit” is not working anymore here an Update about the Logs when running SonarScanner with “–debug” parameter:
[2020-09-10T12:31:34.743Z] 12:31:34.524 INFO: Load New Code definition
[2020-09-10T12:31:34.743Z] 12:31:34.666 DEBUG: GET 200 https://my.sonarqube-instance.com/api/new_code_periods/show.protobuf?project=analyzedproject&branch=minor | time=142ms
[2020-09-10T12:31:34.743Z] 12:31:34.667 INFO: Load New Code definition (done) | time=143ms
[2020-09-10T12:31:34.743Z] 12:31:34.668 INFO: Computing New Code since fork with 'develop'
[2020-09-10T12:31:34.743Z] 12:31:34.668 WARN: Failed to detect fork date. No New Code will be computed.
Thanks.
I’m surprised that the logs in debug don’t show more details about what’s the cause of the problem.
In any case, not having the branch ‘develop’ fetched is definitely a problem. You’ll need to check it out, and also make sure you don’t have a shallow clone.
I’ve retried the Scan without Jenkins Pipeline specifics by just creating a new working copy (git clone) pointing to “default” branch and checking out the desired branch (git checkout).
Same behaviour:
09:46:54.011 INFO: Load New Code definition (done) | time=83ms
09:46:54.012 INFO: Computing New Code since fork with 'default'
09:46:54.012 WARN: Failed to detect fork date. No New Code will be computed.
The analysis on “default” was performed and shows up in SonarQube, I’ve configured ALM Settings in Sonarqube correct (Using Bitbucket Server).
Are there any additional settings I need to configure in sonar-project.properties?
Communication from SonarQube to Bitbucket works (even Pull Request Decorators work)
Attached you will find the whole Scanner Log with Debug Output. It was taken from a smaller Project with Default Branch “master”. Analysis was taken on my Windows Machine (to exclude Jenkins as possible Problem)
Well the good news is that the Git and Svn Plugins will no longer be plugins starting in v8.5 - they’ll be part of SonarQube. That will prevent problems like this from happening again.