sonarqube - 如何在 JenkinsPipeline 中修复与 SonarQube 一起使用的阶段
问题描述
我正在设置我的管道以对 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:$
这个错误表明它期待'}',但我不知道那会在哪里。花括号的嵌套似乎是正确的。
有人可以帮我理解这个错误吗?
谢谢埃里克
解决方案
我认为您缺少sh
orbat
前面的dotnet
(或者是dotnet
一些詹金斯插件实现的詹金斯管道步骤?)。
假设您dotnet
是在您的 linux slave 上为您 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"
}
}
推荐阅读
- apache-kafka - 如何从一种输入类型写入多种输出类型?
- javascript - 为什么我不能创建用户?
- android-studio - 颤振构建运行器不起作用 - 调用了 getter 'uri' 为 null
- r - 当我使用 pivot_longer 按名称排除多个列时出现一元运算符错误
- python - Python - 购买 X 的逻辑在购物篮中免费获得最便宜
- python - 创建 2 个 tkinter 窗口,其中一个“闪烁”打开和关闭
- javascript - 当多个对象项作为数组出现时,将项保存到数据库中的最佳方法是什么?
- terraform - Terraform 输出值在 github 操作中由 jq 格式化失败
- java - Forge Modding 中的“在定义之前无法引用字段”
- terraform - 如果我不想使用本地路径,如何在模块中指定“源”