Checkstyle在Maven中工作正常,但在Jenkins中不起作用。

4
我正在使用Maven、Maven checkstyle插件、Jenkins和Jenkins checkstyle插件。
我总共有7个项目,其中1个是父项目,6个是子项目。
我有以下3种情况:
  1. Checkstyle report for all project.n parent pom i declared checkstyle plugin in tag:

    • I run mvn clean site command

    • It working both ways in eclipse with maven. and in Jenkins also.

    • Giving checkstyle reports for all 7 projects.

  2. Checkstyle report for all project except 2 project.

    • I deleted part in parent pom and i added

    • I added in remaining 4 projects, i declared checkstyle plugin in tag.

    • It working in eclipse but not working in Jenkins.

    Please give solution

    My code:

    <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.

  • I deleted checkstyle plugin in parent
  • I added checkstyle plugin in 4 needed projects same above code.
  • In remaining 2 child projects I added like this.

    <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>
    

  • I run 'mvn clean site'

  • It working in Maven as expected but not working in Jenkins.

我所说的“在Jenkins中无法工作”是指我在Jenkins中安装了Checkstyle插件,在Jenkins任务中选择了“发布Checkstyle分析结果”的复选框。在方案1中,我能够在Jenkins任务页面上看到Checkstyle链接。如果我点击它,所有代码违规报告都会显示出来。但在其他方案(2、3)中,Checkstyle链接也没有出现。


我现在也遇到了完全相同的问题。希望有人能给出答案! - Flipbed
1个回答

2

刚找到了解决方案。

在项目配置菜单中,在“目标和选项”字段中,您需要添加'site',不带'字符。在我的“目标和选项”字段中,我只有:clean install。这没有运行checkstyle。但是我将其更改为:clean install site。现在checkstyle可以正常运行了!

希望这能解决您的问题。

编辑:

我的pom.xml已扩展为以下标签:

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

尝试只使用checkstyle来运行检查,然后再次运行项目。


抱歉,我已经尝试了同样的操作(重新安装网站),但没有任何结果。您能否提供更多细节? - Sun

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接