【发布时间】:2022-11-09 06:11:57
【问题描述】:
我在 ubuntu 20.04 机器上通过带有 docker 的图像安装了 sonarqube。
我正在运行 gitlab 并使用管道执行声纳扫描。对于 python 和 javascript 存储库,这工作得很好,但是我有多个要分析的 c# 项目。
以下脚本在 gitlab-ci.yml 文件中使用:
sonarqube-check:
stage: sonarqube-check
image: mcr.microsoft.com/dotnet/core/sdk:latest
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- "sudo apt-get update"
- "sudo apt-get install --yes openjdk-11-jre"
- "sudo add-apt-repository universe"
- "sudo apt-get install apt-transport-https"
- "sudo dotnet tool update --global dotnet-sonarscanner"
- "export PATH=\"$PATH:/root/.dotnet/tools\""
- "echo $PATH"
- "sudo dotnet tool list -g"
- "sudo dotnet sonarscanner begin /k:\"machtrans_nanders-stand-up_secretkey\" /d:sonar.login=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" "
- "sudo dotnet build"
- "sudo dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\""
allow_failure: true
only:
- chore/implement-sonarqube-check
我已经在 gitlab runner 机器上手动安装了 net-sdk-6.0,它就像这样工作得很好。
当我运行它时,我收到以下错误并尝试了很多东西,但不知道如何解决它,我希望社区中的一个可以帮助我:
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/root/.dotnet/tools
$ sudo dotnet tool list -g
Package Id Version Commands
---------------------------------------------------------
dotnet-sonarscanner 5.5.3 dotnet-sonarscanner
$ sudo dotnet sonarscanner begin /k:"machtrans_nanders-stand-1313216854315" /d:sonar.login="$SONAR_TOKEN" /d:"sonar.host.url=$SONAR_HOST_URL"
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-sonarscanner does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
【问题讨论】:
标签: sonarqube gitlab-ci sonarscanner gitlab-runner