我试图将SonarQube扫描程序设置为在Ubuntu服务器上运行的Jenkins管道的一部分。
我正在运行从https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/4.2.0.1214/sonar-scanner-msbuild-4.2.0.1214-netcoreapp2.0.zip下载的扫描仪版本4.2.0.1214
我运行的命令是:
dotnet /var/lib/jenkins/sonar-scanner/SonarScanner.MSBuild.dll begin /k:"SUP:ThreadManager" /n:"SUP:Thread Manager" /v:"1.0"
dotnet build
dotnet /var/lib/jenkins/sonar-scanner/SonarScanner.MSBuild.dll end
前两行运行正常,但最后一行抛出权限错误,如下所示:
05:30:58 + dotnet /var/lib/jenkins/sonar-scanner/SonarScanner.MSBuild.dll end
05:30:58 SonarScanner for MSBuild 4.1.1
05:30:58 Using the .NET Core version of the Scanner for MSBuild
05:30:58 Default properties file was found at /var/lib/jenkins/sonar-scanner/SonarQube.Analysis.xml
05:30:58 Loading analysis properties from /var/lib/jenkins/sonar-scanner/SonarQube.Analysis.xml
05:30:58 Post-processing started.
05:30:58 SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
05:30:58 Calling the SonarQube Scanner...
05:30:58
05:30:58 Unhandled Exception: System.ComponentModel.Win32Exception: Permission denied
05:30:58 at Interop.Sys.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Int32& lpChildPid, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd)
05:30:58 at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
05:30:58 at System.Diagnostics.Process.Start()
05:30:58 at SonarScanner.MSBuild.Common.ProcessRunner.Execute(ProcessRunnerArguments runnerArgs)
05:30:58 at SonarScanner.MSBuild.Shim.SonarScannerWrapper.ExecuteJavaRunner(AnalysisConfig config, IEnumerable`1 userCmdLineArguments, ILogger logger, String exeFileName, String propertiesFileName)
05:30:58 at SonarScanner.MSBuild.Shim.SonarScannerWrapper.<>c__DisplayClass6_0.<Execute>b__0()
05:30:58 at SonarScanner.MSBuild.Shim.SonarScannerWrapper.Execute(AnalysisConfig config, IEnumerable`1 userCmdLineArguments, ILogger logger)
05:30:58 at SonarScanner.MSBuild.PostProcessor.MSBuildPostProcessor.InvokeSonarScanner(IAnalysisPropertyProvider cmdLineArgs, AnalysisConfig config)
05:30:58 at SonarScanner.MSBuild.PostProcessor.MSBuildPostProcessor.Execute(String[] args, AnalysisConfig config, ITeamBuildSettings settings)
05:30:58 at SonarScanner.MSBuild.BootstrapperClass.PostProcess()
05:30:58 at SonarScanner.MSBuild.BootstrapperClass.Execute()
05:30:58 at SonarScanner.MSBuild.Program.Execute(String[] args, ILogger logger)
05:30:58 at SonarScanner.MSBuild.Program.Main(String[] args)
05:30:58 Aborted (core dumped)
无论用什么用户来运行它,我都会得到相同的错误。使用sudo运行也会出现同样的错误。
任何帮助都会很棒,谢谢。
答案 0 :(得分:1)
以下是为我做的事情:
chmod 777 /opt/sonar-scanner-msbuild-4.2.0.1214-netcoreapp2.0/ -R
如果您想要保持更严格的安全性,那么chmod -x可能也会这样做。
当然,您需要将路径替换为SonarScanner的实际路径