首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SonarScanner在apt-get未找到时失败

SonarScanner在apt-get未找到时失败
EN

Stack Overflow用户
提问于 2022-05-16 11:11:43
回答 2查看 863关注 0票数 1

我已经通过码头映像将SonarQube安装在一台ubuntu机器上。一切正常,我可以在没有问题的情况下登录。

已经连接到我们的GitLab安装并查看了所有可用的项目,当我尝试用以下方式配置现有管道时,我被卡住了。

我正在使用以下pipeline.yml (部分显示在这里):

代码语言:javascript
复制
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: 
      - "apt-get update"
      - "apt-get install --yes openjdk-11-jre"
      - "dotnet tool install --global dotnet-sonarscanner"
      - "export PATH=\"$PATH:$HOME/.dotnet/tools\""
      - "dotnet sonarscanner begin /k:\"my_project_location_AYDMUbUQodVNV6NM7qxd\" /d:sonar.login=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" "
      - "dotnet build"
      - "dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\""
  allow_failure: true
  only:
    - master

一切看起来都很好,但是当它运行时,它给了我这个错误:

代码语言:javascript
复制
$ apt-get update
bash: apt-get: command not found

我只是不知道怎么解决这个问题,在互联网上找不到解决办法

EN

回答 2

Stack Overflow用户

发布于 2022-05-24 11:40:13

dotnet/core/sdk图像具有apt (而不是apt-get):

代码语言:javascript
复制
$ docker run -ti --rm mcr.microsoft.com/dotnet/core/sdk:latest sh
# apt update

SonarCube文档之后,您可以在已经安装的CLI中使用它们的停靠映像:

代码语言:javascript
复制
image:
  name: sonarsource/sonar-scanner-cli:latest
variables:
  SONAR_TOKEN: "your-sonarqube-token"
  SONAR_HOST_URL: "http://your-sonarqube-instance.org"
  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
sonarqube-check:
  stage: test
  script:
    - sonar-scanner -Dsonar.qualitygate.wait=true
  allow_failure: true
  only:
    - master
票数 1
EN

Stack Overflow用户

发布于 2022-05-26 02:51:31

Apt /apt-get命令未找到-问题修复:

我认为在您的/usr/bin中没有apt和apt-get,您可以下载它并在https://packages.debian.org/stretch/apt上安装它,如下所示

代码语言:javascript
复制
wget http://ftp.cn.debian.org/debian/pool/main/a/apt/apt_1.4.9_amd64.deb
dpkg -i apt_1.4.9_amd64.deb
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72258282

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档