gpt4 book ai didi

java - Sonarqube 与 codecommit 集成不起作用

转载 作者:行者123 更新时间:2023-12-02 04:16:02 26 4
gpt4 key购买 nike

我想将 sonarqube 与 codecommit 集成。我的 sonarqube 服务器运行在一台 Linux 服务器上。我想在有人在 codecommit 中 checkin 代码后立即使用 sonarqube 分析我的代码。我如何整合相同的内容。

我在 ubuntu 服务器上安装了 sonarqube。我尝试将 env 变量作为 Sonar 身份验证和 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 命令失败。

最佳答案

不确定这是否是您的问题,但请确保您已将 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/

关于java - Sonarqube 与 codecommit 集成不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56659670/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com