【问题标题】:Sonarqube integration with codecommit not workingSonarqube 与 codecommit 的集成不起作用
【发布时间】:2019-06-19 03:33:57
【问题描述】:

我想将 sonarqube 与 codecommit 集成。我的 sonarqube 服务器在一台 linux 服务器上运行。一旦有人在 codecommit 中签入代码,我想使用 sonarqube 分析我的代码。我怎样才能整合它们。

我在 ubuntu 服务器上安装了 sonarqube。我尝试将 env 变量作为声纳身份验证和 url 放入项目 yaml 文件中,并将mvn sonar:sonar 命令放入构建或构建后部分,但它失败了。

env:
  variables:
    SONAR_LOGIN: "MY_SONARQUBE_AUTHTOKEN"
    SONAR_HOST: "MY_SONARQUBE_URL"
    #You should use parameter-store here instead

phases:
  build:
    commands:
      - mvn test
  post_build:
    commands:
      - mvn sonar:sonar -Dsonar.login=$SONAR_LOGIN -Dsonar.host.url=$SONAR_HOST

它应该在 sonarqube 页面上给出结果,但是找不到 mvn sonar:sonar 命令失败。

【问题讨论】:

  • 欢迎来到 Stack Overflow!请查看writing the perfect question 以帮助您提出一个好问题,从而得到一个好的答案。您需要提供更多相关(日志记录和版本)信息。

标签: java sonarqube aws-codecommit


【解决方案1】:

不确定这是否是您的问题,但请确保您已将 maven 安装到您的 ubuntu CodeBuild 容器中。

phases:
  install:
    runtime-versions:
      java: openjdk11

  commands:
  - apt-get install -y maven

另外,请确保您已将 SonarScanner 插件添加到您的 settings.xml 中

<settings>
<pluginGroups>
    <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profiles>
    <profile>
        <id>sonar</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <!-- Optional URL to server. Default value is http://localhost:9000 -->
            <sonar.host.url>
              http://myserver:9000
            </sonar.host.url>
        </properties>
    </profile>
 </profiles>

设置来源:https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-maven/

【讨论】:

    猜你喜欢
    • 2015-08-11
    • 2022-01-03
    • 2016-06-29
    • 2017-01-19
    • 2018-02-17
    • 2018-10-17
    • 2014-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多