This is an unfortunately vague error. You should make sure that the user account running the pipeline has permissions to read/execute the scanner, and full (rwx) permissions to the project directory.
This is on the OS / Jenkins side. What user is Jenkins running as on that build agent? And does that user account have full permissions to the Jenkins work directory?
install dotnet code on the jenkins node that you want to run the analysis on i would assume. If i recall correctly the jenkins plugin for sonarqube will only inject some configuration and not take care of the provisioning of your build nodes.
You can find more information about the requirements of the dotnet scanner here: SonarScanner for .NET | SonarQube Docs
Additionally here is a tutorial how to manually install dotnet core on ubuntu 20.04: How to Install Dotnet Core on Ubuntu 20.04 – TecAdmin
Sorry, I made a mistake, I created the directory /usr/bin/dotnet/ before installing dotnet. Because of this, the dotnet installation did not work correctly. I fixed it and everything worked. Thank you! But there is one more question, a little later I will write it.
stage("SonarQube scan") {
steps {
echo "===============Scan Sonar======================="
script {
git branch: "main",
url: "git@github.com:VladimirKazantsev/c-app.git"
def scannerHome = tool 'SonarQube-1'
sh "ls"
sh "pwd"
println "${scannerHome}"
withSonarQubeEnv(installationName: 'sonarqubeElets') {
sh "which dotnet"
sh "dotnet ${scannerHome}/SonarScanner.MSBuild.dll begin /k:\"testVladimir\" /d:sonar.verbose=true /d:sonar.login=\"sqp_5111c5b096cf74f8f17cccb9c0bd3d8de1ebf943\""
sh "dotnet build Helloworld.csproj"
sh "dotnet ${scannerHome}/SonarScanner.MSBuild.dll end /d:sonar.login=\"sqp_5111c5b096cf74f8f17cccb9c0bd3d8de1ebf943\""
}
}
}
}
Then I get the following error
+ dotnet /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube-1/SonarScanner.MSBuild.dll begin /k:testVladimir /d:sonar.verbose=true /d:sonar.login=sqp_5111c5b096cf74f8f17cccb9c0bd3d8de1ebf943
17:40:46 Failed to execute because the specified command or the specified file could not be found.
17:40:46 Possible reasons:
17:40:46 * you mistyped the built-in dotnet command;
17:40:46 * you were planning to run a .NET program, but it dotnet-/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube-1/SonarScanner.MSBuild.dll doesn't exist;
17:40:46 * you wanted to run a global tool, but the path specified in PATH could not find an executable file with the dotnet prefix that has this name.