我正在运行下面的管道,该管道的dotnetcore 2.2处于“构建+ Sonarscanner分析”阶段。
阶段设置如下
// Tools
MSBUILD_SQ_SCANNER_HOME = tool name: 'Scanner_for_MSBuild_4.7', type: 'hudson.plugins.sonar.MsBuildSQRunnerInstallation'
stage ('Build + SonarQube analysis') {
agent {
docker {
image 'mcr.microsoft.com/dotnet/core/sdk:2.2'
}
}
steps {
dir ("app") {
withSonarQubeEnv('local') {
sh "dotnet ${MSBUILD_SQ_SCANNER_HOME}/SonarScanner.MSBuild.dll begin /k:\"Testing-Local\""
sh "dotnet build ${env.DotnetProjectName}"
sh "dotnet ${MSBUILD_SQ_SCANNER_HOME}/SonarScanner.MSBuild.dll end"
}
}
}
}
结果
我正在获取SonarScanner.MSBuild.dll如下图所示无法执行
验证
stage ('Build + SonarQube analysis') {
agent {
docker {
image 'mcr.microsoft.com/dotnet/core/sdk:2.2'
}
}
steps {
dir ("app") {
withSonarQubeEnv('local') {
sh "dotnet /var/lib/jenkins/tools/hudson.plugins.sonar.MsBuildSQRunnerInstallation/Scanner_for_MSBuild_4.7/SonarScanner.MSBuild.dll begin /k:\"Testing-Local\""
sh "dotnet build ${env.DotnetProjectName}"
sh "dotnet var/lib/jenkins/tools/hudson.plugins.sonar.MsBuildSQRunnerInstallation/Scanner_for_MSBuild_4.7/SonarScanner.MSBuild.dll end"
}
}
}
}
非常感谢您的帮助。
答案 0 :(得分:0)
我能够解决这个问题,
1。在Jenkins Tools中安装了适用于dotnetcore的SonarScanner
声纳扫描仪的路径将与以前相同
默认路径
/var/lib/jenkins/tools/hudson.plugins.sonar.MsBuildSQRunnerInstallation/Scanner_for_MSBuild_4.7/SonarScanner.MSBuild.dll
2。在Jenkinsfile中初始化工具
// Tools
MSBUILD_SQ_SCANNER_HOME = tool name: 'Scanner_for_MSBuild_4.7', type: 'hudson.plugins.sonar.MsBuildSQRunnerInstallation'
stage ('Build + SonarQube analysis')
agent {
docker {
image 'mcr.microsoft.com/dotnet/core/sdk:2.2'
args '-v ${MSBUILD_SQ_SCANNER_HOME}:/opt/sonarscanner'
}
}
steps {
dir ("app") {
withSonarQubeEnv('local') {
sh "dotnet /opt/sonarscanner/SonarScanner.MSBuild.dll begin /k:\"Testing-Local\""
sh "dotnet build ${env.DotnetProjectName}"
sh "dotnet /opt/sonarscanner/SonarScanner.MSBuild.dll end"
}
}
}
}
它如何工作?