Hello all. Quite new with sonnar. So far I was able to configure in jenkins my sonarqube server and run maven apps with following code.
withSonarQubeEnv('sonarserver') {
sh 'mvn clean package sonar:sonar'
s
}
This runs successfully and do the analysis plus the maven build and generates a war file.
Now I´m trying to do the same for .net core app. I installed sonarscanner following this link
First step was successfully run
dotnet tool install --global dotnet-sonarscanner
I got:
dotnet tool install --global dotnet-sonarscanner
Since you just installed the .NET Core SDK, you will need to logout or restart your session before running the tool you installed.
You can invoke the tool using the following command: dotnet-sonarscanner
So I created following code next:
withSonarQubeEnv('sonarserver') {
sh '''
dotnet-sonarscanner begin /k:"proyject-key"
dotnet build solution.sln
dotnet-sonarscanner end
'''
But now I´m getting:
+ dotnet-sonarscanner begin /k:project-key
/var/lib/jenkins/workspace/sonar-test-dotnet@tmp/durable-00ff368b/script.sh: 3: /var/lib/jenkins/workspace/sonar-test-dotnet@tmp/durable-00ff368b/script.sh: dotnet-sonarscanner: not found
[Pipeline] }
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeed?
What Am I missing and how can I configure it? Didn´t the sonnar scanner already installed in first step?
I’m no .net developer so i’m also looping in @mickaelcaro for the .net perspective.
I did notice that the documentation you linked refers to dotnet sonarscanner begin .... and dotnet sonarscanner end and in your code snippet I see a - between dotnet and sonarscanner. Could this be the issue?
This is also something I see in the log output dotnet-sonarscanner: not found.
I think your snippet should look like this:
withSonarQubeEnv('sonarserver') {
sh '''
dotnet sonarscanner begin /k:"project-key"
dotnet build solution.sln
dotnet sonarscanner end
'''
Can you check that the .dotnet folder (usually $HOME/.dotnet/tools) where your tool and SDKs might be installed is registered on your $PATH env variable ?