Reputation: 11
I am trying to run the following command to scan dotnet core project using sonarqube in Jenkins pipeline
sh "dotnet sonarscanner begin /k:projectkey1"
sh "dotnet build"
sh "dotnet sonarscanner end"
Gives me the following error
+ dotnet sonarscanner begin /k:projectkey1
No executable found matching command "dotnet-sonarscanner"
I can login to the same server as user jenkins and run the same command without any issues. Please help
Upvotes: 1
Views: 2218
Reputation: 39
You need to set the dotnet tools path in the Jenkins pipeline.
Try:
sh "export PATH=${PATH}:${HOME}/.dotnet/tools"
before your steps in the pipeline:
sh "dotnet sonarscanner begin /k:projectkey1"
sh "dotnet build"
sh "dotnet sonarscanner end"
Upvotes: 1
Reputation: 1873
Be sure that the user account being used for the agent in the pipeline is the same one that you've logged into and installed the sonarscanner
global CLI tool on. Because .NET Core Global Tools are user-specific, it won't be available is the users are different.
If you're certain it's the same user, then it's likely caused by cmd.exe needing to be restarted.
If all else fails, you can use SonarScanner.MSBuild.dll
for .NET Core instead of the global CLI tool.
Upvotes: 0