How to do a fresh scan on main branch?

Hello,

I’d like to scan my main branch as if it my project was new, in order to report all the problems.
How to set up my project ?

Thanks.

Hi,

Analysis always reports all the problems on a long-lived branch.

Go to the Branches page and double-check your long-lived branches pattern, shown in the top-right. Edit as needed (this is a regex, not a glob) to make sure your branch will be recognized as long-lived. Delete the branch from SonarQube Cloud if it already exists. Then analyze.

 
HTH,
Ann

Hello,

In my long-lived branches, I had master as MAIN BRANCH, and.. main. I had previously develop and main, and I renamed develop to master for (unsuccessfull) tests with Sonar.

I had no develop branch anymore in Sonar, but I reset the setting for long-lived branches, and I put there only develop (which points to the same commit as master):
develop

I still have the develop branch on Git, and I ran in Jenkins a build for this branch. SonarCloud doesn’t show any error, because it says no code has been changed…

Hi,

I’m not sure I understand what you intend to convey here.

How about a screenshot?

 
Ann


image

Git branches (capture of GitKraken GUI):

master, main, and develop point to the same commit.

An analysis on master has previously be done.

I send you the log through PM.

Hi,

It doesn’t look to me from these screenshots like a branch named develop has been analyzed.

Make sure your analysis includes the parameter sonar.branch.name=develop. Normally this would be picked up automatically from your environment by the integration and passed forward. But if you’re doing some slight-of-hand with what the branch actually is, you’ll need to set it manually.

 
HTH,
Ann

It was already set by the CI scripts, as seen in the Jenkins log:

14:02:00  [2025-03-19T13:02:00.045Z] Running SonarScanner with suffix -'Dsonar.branch.name=develop'..

Hi,

That shows up in your log:

Branch name: develop, type: long-lived

Has the branch still not shown up? You should check your background tasks (under Administration).

 
Ann

No, it still doesn’t appear in the SonarCloud GUI, and the concered builds are not int he background tasks either.
From what I understand, the scanner doesn’t see any difference (with what ?), so it doesn’t send anything to the SonarCloud.

Hi,

I’ve just scrolled to the end of your analysis log. Did you do that?

 
Ann

Hey Robert,

I guess this thread helps for your issue " How to change the main branch in SonarQube? - #8 by trexx00 ".

1 Like

Yes. What piece of log do you have in mind ? This one ?

14:02:17.639 INFO  63/63 files marked as unchanged

But the subject is precisely to do a fresh scan.

Hi,

No, I mean this one:

14:02:18.740 INFO EXECUTION FAILURE

A failed analysis doesn’t upload anything to the server.

 
Ann

Yes, it failed because there wasn’t any difference.
But my question remains: what could I do to prevent the scanner search for differences, and to make it do a full scan ?

Hi,

Can we have a debug log?

 
Ann

Hello,

OK, I just sent you the log.

Hi,

Are you doing a full, clean build before analysis?

 
Ann

Hi,

Yes, we delete the full Jenkins workspace, and rebuild all.

I keep the thread alive while I’m trying to resolve it though private message.
So I’ll be able to (maybe) put the ultimate answer before it is automatically closed!

Hi,

Autoclose only happens after (if!) you mark a post the solution.

 
:slight_smile:
Ann

1 Like