【问题标题】:one master pom file with multiple profiles and sonar analysis for each profile一个包含多个配置文件的主 pom 文件和每个配置文件的声纳分析
【发布时间】:2015-10-29 13:27:19
【问题描述】:

我的项目总共有 50 个模块和 10 个配置文件。 5 个配置文件用于构建 5 个产品,5 个配置文件用于对相同的 5 个产品进行单元测试。

30 个通用模块和 4 个模块用于构建每个产品的每个配置文件。 现在我必须看看如何将 SONAR 分析与每个产品的 Jenkins 工作集成。

我需要在声纳中看到 5 个条目,每个产品一个,但我有一个 pom 文件。这个可以实现吗?

请帮忙。下面的示例 pom 文件

<modules>
        <!-- Script related projects -->
        <!-- Common modules -->
        <module>./././bundles/com.abc.module1</module>
        <module>./././bundles/com.abc.module2</module>
            .
            .
        <module>./././bundles/com.abc.module30</module>
</modules>

<profiles>
        <profile>
            <id>product1</id>
            <modules>
                <module>./././bundles/com.abc.module31</module>
                <module>./././bundles/com.abc.module32</module>
            </modules>
        </profile>

        <profile>
            <id>product1-tests</id>
            <modules>
                <module>./././bundles/com.abc.testmodule1</module>
                <module>./././bundles/com.abc.testmodule2</module>
            </modules>
        </profile>
        .
        .
        .

</profiles>

【问题讨论】:

标签: maven jenkins sonarqube pom.xml maven-profiles


【解决方案1】:

如果您现在没有,我只需创建一个包含所有源模块的配置文件,并有一个运行声纳的 jenkins 作业来构建和分析该单个配置文件。 Sonar 将为您的源提供质量指标和覆盖范围,因此您只需要一个包含所有源的声纳项目。此配置文件应包含您的测试,但仅用于在测试运行时收集覆盖率数据 - 您不需要对测试进行质量测量(除非您对这类事情感兴趣)。

【讨论】:

  • 嗨 tdrury,我已经有了这个 pom 配置来构建和单元测试我的 5 个项目。我的问题是没有在 sonarqube 中对所有 5 进行声纳分析。这可以实现吗?
  • 您希望它们作为 Sonar 中的 1 个项目还是 5 个项目?
  • 我需要 5 个不同的声纳项目
  • 然后将声纳构建后操作添加到您的工作中,但请确保您在高级选项中设置了分支名称,并且每个声纳项目的名称必须不同。或者,您可以创建 5 个新的 jenkins 作业来运行声纳操作并将每个的分支名称设置为不同的值。
【解决方案2】:

Sonar 基于“artifactId”标签构建项目。因为对于一个 pom 文件,我们只有 1 个“artifactId”,所以我们只能在 sonarqube 中列出 1 个项目。我们必须为多个声纳项目条目提供多个 pom 文件。 谢谢。

【讨论】:

    猜你喜欢
    • 2016-08-31
    • 2013-02-22
    • 1970-01-01
    • 2016-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-16
    • 2013-11-22
    相关资源
    最近更新 更多