【问题标题】:Checkstyle working in Maven, but not working in JenkinsCheckstyle 在 Maven 中工作,但不在 Jenkins 中工作
【发布时间】:2013-09-27 15:23:28
【问题描述】:

我正在使用 Maven、Maven checkstyle 插件、Jenkins 和 Jenkins checkstyle 插件。

我总共有 7 个项目。 1 个父项目和 6 个子项目。

我有以下三种情况:

  1. 所有 project.n 父 pom 的 Checkstyle 报告我在标签中声明了 checkstyle 插件:

    • 我运行mvn clean site 命令

    • 它在 Eclipse 中与 maven 双向工作。在 Jenkins 中也是如此。

    • 为所有 7 个项目提供检查样式报告。

  2. 除了 2 个项目之外的所有项目的 Checkstyle 报告。

    • 我删除了父 pom 中的部分并添加了

    • 我在剩下的4个项目中添加了,我在标签中声明了checkstyle插件。

    • 它在 Eclipse 中工作,但在 Jenkins 中不工作。

    请给出解决方案

    我的代码:

    <reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.10</version>
            <configuration>
                <configLocation>../parent-project/checkstyle.xml</configLocation>
            </configuration>
        </plugin>
    </plugins>
    

3.

  • 我删除了父级中的 checkstyle 插件
  • 我在与上述代码相同的 4 个需要的项目中添加了 checkstyle 插件。
  • 在剩下的 2 个子项目中我这样添加。

    <reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.10</version>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
    </plugins>
    

  • 我运行“mvn clean site”

  • 它在 Maven 中按预期工作,但在 Jenkins 中不工作。

我所说的“不在 Jenkins 中工作”的意思是我在 Jenkins 中安装了 checkstyle 插件,在 Jenkins 工作中我选择了“发布 Checkstyle 分析结果”复选框。在场景 1 中,我可以在 jenkins 工作页面中看到 checkstyle 链接。如果我点击所有代码违规报告都会出现。在其他情况下 (2,3) Checkstyle 链接也不会出现。

【问题讨论】:

  • 我自己现在也有同样的问题。希望有人给个答案!

标签: maven jenkins maven-3 jenkins-plugins checkstyle


【解决方案1】:

刚刚找到解决办法。

在项目配置菜单中,在“目标和选项”字段中,您需要添加不带 ' 字符的 'site'。在我的“目标和选项”字段中,我有:全新安装。这没有运行 checkstyle。但后来我将其更改为:全新安装站点。现在 checkstyle 运行了!

希望这能解决您的问题。

编辑:

我的 pom.xml 已经扩展了标签:

<reporting>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>2.10</version>
  </plugin>
</plugins>

运行 checkstyle。尝试仅将其用于 checkstyle,然后再次运行项目。

【讨论】:

  • 对不起,我做了同样的事情(干净的安装站点)但没有结果。您能否提供更多详细信息。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-09-15
  • 1970-01-01
  • 2011-09-15
  • 2014-03-21
  • 2014-01-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多