Sonarqube is not showing Msbuild analysis

Hello Team,

we are having sonarqube 7.9.3 community edition & sonar scanner for msbuild .net 5.2.1, our jenkins is has linux agent

our Jenkins build gets successful but we are not seeing any results on sonarqube dashboard ,

sonarqube logs :----------
2021.06.08 14:29:50 INFO  ce[AXnrmZmrViTuBNQnmTsV][o.s.c.t.CeWorkerImpl] Executed task | project=project:vek-orabr | type=REPORT | id=AXnrmZmrViTuBNQnmTsV | submitter=s2-service-account | status=SUCCESS | time=6230ms

jenkins job :-----------
$dotnet_home begin /key:"project:vek-orabr"  /d:sonar.login="e0602b05c77f7616e6de" /d:sonar.host.url=https://example.com/sonarqube  /d:sonar.verbose=true /d:sonar.cs.opencover.reportsPaths="test/*/coverage.opencover.xml"


# $dotnet_home build VEK.Orchestrator.sln
DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet --info
dotnet publish
cd VEK.Orabrr.Api/bin/Debug/net5.0/publish/
echo `git rev-parse --short HEAD` >> version.txt
zip -r ../../../../../VEK-Orabr.zip *
# $dotnet_home end 

what we need to check to get result on sonarqube dashboard,since jenkins builds are getting completed but no analysis on SQ dashboard, please guide us,

Regards,
Sam

What output appears in the Jenkins log for the begin and end steps?

Note that if you are calling the Scanner for .NET directly from script you should be calling dotnet sonarscanner begin and dotnet sonarscanner end as documented here.

@duncanp

Thanks for your guidance we have gone thru the suggestion & found that we are calling sonar scanner correctly as documented in that link

some info to refer

./dotnet-sonarscanner begin /key:"project:vek-orabr"  /d:sonar.login="e0602b05c77f7616e6de" /d:sonar.host.url=https://example.com/sonarqube  /d:sonar.verbose=true /d:sonar.cs.opencover.reportsPaths="test/*/coverage.opencover.xml"


dotnet build VEK.Orchestrator.sln
DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet --info
dotnet publish
cd VEK.Orabrr.Api/bin/Debug/net5.0/publish/
echo `git rev-parse --short HEAD` >> version.txt
zip -r ../../../../../VEK-Orabr.zip *
# ./dotnet-sonarscanner end 

but still it is not pushing but we can see background task and even sonarqube logs says it is successful

SQ LOGS:


2021.06.08 14:29:50 INFO  ce[AXnrmZmrViTuBNQnmTsV][o.s.c.t.CeWorkerImpl] Executed task | project=project:vek-orchestrator | type=REPORT | id=AXnrmZmrViTuBNQnmTsV | submitter=s2-service-account | status=SUCCESS | time=6230ms

Our Jenkins Agent is Linux.

Please guide us where to check to resolve this issue, or it is a default behavior.

Regards,
Sameer

Please share the logs for the dotnet build step and the scanner end step.

@duncanp
I have attached build logs, please check and guide.
msbuildlogs.txt (1.6 MB)

also we observed
if we run end command it is throwing error,

12:24:55 + dotnet end
12:24:55 Could not execute because the specified command or file was not found.
12:24:55 Possible reasons for this include:
12:24:55 * You misspelled a built-in dotnet command.
12:24:55 * You intended to execute a .NET program, but dotnet-end does not exist.
12:24:55 * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

@samkhamk as I pointed out in my first answer, you should be calling

dotnet sonarscanner end

and not

dotnet end

@duncanp

yes we also tried that, we get below errors

12:28:46 + /home/.dotnet/tools/./dotnet-sonarscanner end
12:28:46 SonarScanner for MSBuild 5.2.1
12:28:46 Using the .NET Core version of the Scanner for MSBuild
12:28:46 Post-processing started.
12:28:46 08:58:46.273 Temporary analysis directory (usually .sonarqube) doesn’t exist. The “begin” step was probably not executed.
12:28:46 08:58:46.274 Post-processing failed. Exit code: 1

@samkhamk the begin, build and end stages all need to be run from the same directory. It looks like your build script is changing the directory between build and end.

Try moving the end step before you change directory, or temporarily comment out the change of directory to see what happens.

1 Like

@duncanp

Good catch and thanks for your support & help it is publishing the results in sonarqube board,
Many thanks for your help.

1 Like