Branch analysis new code with Jenkins

Using Sonarqube Developer Edition Version 8.4.1 (build 35646)

Similarly to this question: https://community.sonarsource.com/t/setting-reference-branch-at-a-project-settings-level-will-display-this-branch-is-configured-to-use-itself-as-reference-branch-for-all-branches/28413/18. I am trying to set a reference branch in sonarqube, but get:

This branch is configured to use itself as reference branch. It will never have New Code.

as an error, even though the branch is set to use a different branch as reference.

I am using jenkins as my automation server, and get the following as an error in my logs:

12:48:26.599 WARN: No fork point found between HEAD and refs/remotes/origin/develop
12:48:26.599 WARN: Failed to detect fork date. No New Code will be computed.

How should I configure sonarqube/jenkins to allow for New Code calculation?

1 Like

Hi,

Welcome to the community!

Could you see if this thread helps?

 
Ann

That thread talks about similar issues to mine (Sonarqube is unable to parse the git tree because of how one clones/checkouts code), but the resolution was to checkout in a special way to allow Sonarqube to understand it.

I am hoping to receive advice on what Sonarqube expects in terms of git knowledge/structure so that I know how to fix my issue.

1 Like

In my case I see no messages pointing to a possible cause:

Load New Code definition
Load New Code definition (done) | time=58ms
Computing New Code since fork with 'master'
Failed to detect fork date. No New Code will be computed. 

Tried both GoCD and local builds, but the results were the same. New code detection in PRs was okay. Help would be appreciated.

Right now the following at least works, but not the most ideal:

  • Setting New Code detection back to 30 days period by default.
  • Creating branch X.
  • Pushing branch X in Git without changes compared to master. (This step should be unnecessary.)
  • Doing an initial analysis on branch X. (This step should be unnecessary.)
  • Pushing changes to branch X.
  • Rerunning the analysis.
1 Like

We had similar issues ('New Code' on feature branch being polluted with details from mainline).

One of the things that helped us get past this issue is to use pullRequest information when doing the sonar-scan. I cannot deeply explain it, but telling the scan to use PR info rather than straight up branch-comparison radically improved the ability for sonar to correctly calculate the ā€˜new codeā€™

It looks similar to "The scanner failed to compute New Code".
Check if you need to upgrade the sonar-scm-git plugin to v1.12.0.2034.

Hi, I am also facing the same issue. Sonar Qube version using is Version 8.5.1.
But canā€™t find anything in the marketplace to upgrade the sonar-scm-git plugin to v1.12.0.2034.

Thanks

Hi @yuga_Paranjape,

By 8.5 all the plugins are ā€œbaked-inā€ & not updatable outside of a SonarQube update. You should already have the latest version of that integration. Please open a new thread for your problem and give us the details.

Ā 
Ann