我正在设置管道以对dotnet项目进行SonarQube扫描。这是阶段:
stage('SonarQube analysis') {
withSonarQubeEnv('My Sonar') {
dotnet "/usr/local/sonar-scanner-msbuild/SonarScanner.MSBuild.dll" begin /k:${SONARQUBEPROJECTKEY}
dotnet build "src/hub-backend.sln"
dotnet "/usr/local/sonar-scanner-msbuild/SonarScanner.MSBuild.dll" end
}
}
但是,它失败并返回此错误:
Obtained Jenkinsfile from git https://<removed>/scm/<removed>/jenkins-stuff.git
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 30: expecting '}', found 'begin' @ line 30, column 84.
ild/SonarScanner.MSBuild.dll" begin /k:$
此错误表示正在期待'}',但我不知道该在哪里。花括号的嵌套似乎是正确的。
有人可以帮助我理解此错误吗?
谢谢 埃里克
答案 0 :(得分:1)
我认为您在sh
前面缺少bat
或dotnet
(或者dotnet
是由某些jenkins插件实现的jenkins管道步骤吗?)。 / p>
假设您的dotnet
是为Linux奴隶上的jenkins用户安装的命令。
stage('SonarQube analysis') {
withSonarQubeEnv('My Sonar') {
sh "dotnet \"/usr/local/sonar-scanner-msbuild/SonarScanner.MSBuild.dll\" begin /k:${SONARQUBEPROJECTKEY}"
sh "dotnet build \"src/hub-backend.sln\""
sh "dotnet \"/usr/local/sonar-scanner-msbuild/SonarScanner.MSBuild.dll\" end"
}
}