Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jenkins/Maven checkstyle:签入pom.xml不起作用_Maven_Jenkins_Pom.xml_Checkstyle - Fatal编程技术网

Jenkins/Maven checkstyle:签入pom.xml不起作用

Jenkins/Maven checkstyle:签入pom.xml不起作用,maven,jenkins,pom.xml,checkstyle,Maven,Jenkins,Pom.xml,Checkstyle,我已经编写了以下pom.xml文件,它应该创建一个checkstyle报告/趋势图,并在出现一些checkstyle警告时中止构建过程 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apach

我已经编写了以下pom.xml文件,它应该创建一个checkstyle报告/趋势图,并在出现一些checkstyle警告时中止构建过程

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>test</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>test</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <reporting>
   <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.8</version>
        <reportSets>
            <reportSet>
              <reports>
                <report>checkstyle</report>
              </reports>
            </reportSet>
          </reportSets>
          <configuration>
            <configLocation>https://dustplanet.de/checkstyle.xml</configLocation>
        </configuration>
      </plugin>
      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.7</version>
        </plugin>
    </plugins>
  </reporting>
  <build>
     <pluginManagement> 
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugin</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>2.17</version>
          <executions>
            <execution>
                <phase>validate</phase>
                <goals>
                    <goal>check</goal>
                </goals>
                <configuration>
                     <consoleOutput>true</consoleOutput>
                     <failsOnError>true</failsOnError>
                    <failOnViolation>true</failOnViolation>
                </configuration>
            </execution>
         </executions>
        </plugin>
      </plugins>
      </pluginManagement> 
       <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.17</version>
      </plugin>
    </plugins>   
    </build>

</project>
有人知道我做错了什么吗

编辑1 好的,我现在知道了,构建序列中的checkstyle插件不能正常工作,因为我现在收到了这个警告

[INFO] Scanning for projects...
[WARNING] The POM for org.apache.maven.plugin:maven-checkstyle-plugin:jar:2.17 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugin:maven-checkstyle-plugin:2.17: Plugin org.apache.maven.plugin:maven-checkstyle-plugin:2.17 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugin:maven-checkstyle-plugin:jar:2.17 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building test 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.maven.plugin:maven-checkstyle-plugin:jar:2.17 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugin:maven-checkstyle-plugin:2.17: Plugin org.apache.maven.plugin:maven-checkstyle-plugin:2.17 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugin:maven-checkstyle-plugin:jar:2.17 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
只有当我将checkstyle插件放在构建序列中时,它们才会发生,而报告序列中的checkstyle插件工作正常。如何解决此问题

编辑2


好的,问题是我在
org.apache.maven.plugin
中的plugin后面忘记了一个“s”。该插件仍然无法执行,但我现在在jenkins中将构建标记为不稳定或失败。我应该以第一种可能的方式来帮助您。

您需要在
pom.xml
中添加
maven checkstyle plugin
报告插件,您可以使用以下插件:

<project>
  ...
   <reporting>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>2.17</version>
          <reportSets>
            <reportSet>
              <reports>
                <report>checkstyle</report>
              </reports>
            </reportSet>
          </reportSets>
        </plugin>
      </plugins>
    </reporting>
  ...
</project>

...
org.apache.maven.plugins

我不确定您想要实现什么,但您的构建过程中断会导致出现checkstyle错误:
[error]src/main/java/test/test/App.java:[11,43](空格)WhitespaceAround:'{'前面没有空格…
。?我希望在出现checkstile错误时,生成过程会失败,但我的checkstyle趋势图以及jenkins的分析报告也会得到正确更新。现在我只能实现生成过程中断或趋势图得到正确更新,而不是both在一起。抱歉,如果很难理解我,我也是新来的jenkins和maven,我的英语也不是最好的。mhm我已经在上面的pom.xml中这样做了。问题不是没有创建报告,问题是如果构建过程中断,jenkins的分析报告和图表趋势没有以正确的方式得到更新该部分中的checkstyle插件似乎无法正常工作。
<project>
  ...
   <reporting>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>2.17</version>
          <reportSets>
            <reportSet>
              <reports>
                <report>checkstyle</report>
              </reports>
            </reportSet>
          </reportSets>
        </plugin>
      </plugins>
    </reporting>
  ...
</project>