jenkins - 不推荐使用 SonarQube 构建后操作

标签 jenkins java-8 sonarqube maven-3 sonarqube-scan

使用 Jenkins 1.642.2 和 SonarQube 5.6.1 对我所有的 maven 项目进行代码分析。

当我使用 maven 目标 Sonar : Sonar 时,他们需要更多时间来分析文件(按文件超过 7 秒):

[INFO] Sensor SCM Sensor
[INFO] SCM provider for this project is: svn
[INFO] 1079 files to be analyzed
[INFO] 
[INFO] 2/1079 files analyzed
[INFO] 3/1079 files analyzed
[INFO] 4/1079 files analyzed
[INFO] 5/1079 files analyzed

当我使用带有此配置的 SonarQube 扫描仪时:

SonarQube Server

SonarQube scanner

SonarQube scanner

然后我有这个错误:
WARN: Property 'sonar.jdbc.url' is not supported any more. It will be  ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
INFO: User cache: /var/lib/jenkins/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=43ms
INFO: SonarQube server 5.6.1
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is  platform dependent)
INFO: Process project properties
INFO: ---------------------------------------------------------------------- --
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.621s
INFO: Final Memory: 39M/132M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'Unknown':   sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug    logging.
Build step 'Execute SonarQube Scanner' marked build as failure
Finished: FAILURE

我的设置文件:
<profile>
        <id>sonar</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <sonar.jdbc.url>
            jdbc:mysql://11.230.5.88:3306/sonar
            </sonar.jdbc.url>
            <sonar.jdbc.username>sonar</sonar.jdbc.username>
            <sonar.jdbc.password>sonar</sonar.jdbc.password>
            <!-- Optional URL to server. Default value is http://localhost:9000 -->
            <sonar.host.url>
              http://sonarqube-groupe.com/
            </sonar.host.url>
        </properties>
    </profile>

解决这个问题的任何想法,因为我有一个问题来理解新的 Sonar 使用

我必须为 Maven 项目制作一个 sonar-project.properties 文件吗?

最佳答案

您可以并且仍然应该使用构建步骤使用 Maven 进行分析。如前所述in the docs ,您应该首先在全局配置级别“启用 SonarQube 服务器配置注入(inject)”,然后在您的构建中启用构建环境选项“准备 SonarQube 扫描仪环境”。然后您可以将您的 Maven 目标设置为以下内容:

$SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN

关于jenkins - 不推荐使用 SonarQube 构建后操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39750436/

相关文章:

continuous-integration - Jenkins/Hudson 中的跨项目依赖关系

unit-testing - TestStack White - 从命令行运行测试

testing - 如何使用 Jenkins 生成 mocha 测试用例报告并展示?

java - 在 Java 8 上我无法继承重写的继承注释

azure-active-directory - Azure AD 与 sonarqube 集成

java - SonarQube - mvn Sonar : sonar - NoSuchElementException

python - jenkins 通过请求发布作业 xml 失败并出现异常

java - 既然我们已经有了 StringBuilder,为什么还要使用 StringJoiner?

java - 递归流

c# - SonarQube 分析无法完成,因为找不到分析配置文件