SonarCloud analyzes feature branches as Overall Code instead of New Code (Jenkins Freestyle)

ALM used

GitHub


CI system used

Jenkins Freestyle (multibranch pipeline)


Scanner command used when applicable (private details masked)

/home/jenkins/sonar-scanner-7.1.0.4889-linux-x64_3/bin/sonar-scanner \
  -Dsonar.projectKey=hdiseguroscol_${REPO_NAME} \
  -Dsonar.organization=hdi-seguros-colombia \
  -Dsonar.host.url=https://sonarcloud.io \
  -Dsonar.sources=src \
  -Dsonar.exclusions=**/test.js,**/*.test.js \
  -Dsonar.sourceEncoding=UTF-8 \
  -Dsonar.branch.name=${env.BRANCH_NAME}


Languages of the repository

JavaScript / Node.js (npm build)


SonarCloud project URL (only if public)

Private (cannot share)


Error observed

In SonarCloud Teams Edition, we’re observing that feature branches (feature/*) are analyzed as Overall Code instead of New Code, which causes old issues (already present in main) to appear as new.

The New Code Definition in Teams Edition only allows “Previous Version” or “Number of Days”, so we cannot set Reference Branch.

Even though our main branch analysis works correctly, every time we analyze a feature branch, SonarCloud treats the code of the branch as Overall Code.

This results in hundreds of legacy issues being raised as if they were newly introduced.

Is there a supported method in SonarCloud Teams Edition to make short-lived branches compare their analysis baseline against main, so that New Code is computed correctly (and old issues aren’t re-raised)?

Thanks in advance for any clarification or official guidance :folded_hands:

Hey there.

Do you mean that your branches are being analyzed as long-lived branches (you see a tab for both overall code and new code in your branch dashboard), or as short-lived branches (all the code is appearing as if it’s New Code, when in fact it’s not).

A screenshot might be helpful here!