我在嘗試讓checkstyle在Hudson/Jenkins中正常工作時遇到問題。獲取Checkstyle自定義規則以在Hudson/Jenkins中工作
我創造了非常小的規則自定義的CheckStyle規則在它(只是爲了看看它的工作原理),並將其放置在某些服務器: -
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="RegexpSingleline">
<property name="format" value="\s+$" />
<property name="minimum" value="0" />
<property name="maximum" value="0" />
<property name="message" value="Line has trailing spaces." />
</module>
</module>
我有一個看起來像這樣的父POM: -
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>a.b</groupId>
<artifactId>c</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.4</version>
<configuration>
<configLocation>http://server/checkstyle.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
實際的項目將包括父POM,像這樣: -
<?xml version="1.0" encoding="UTF-8"?>
<project>
<parent>
<groupId>a.b</groupId>
<artifactId>c</artifactId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>some</groupId>
<artifactId>project</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
...
</project>
當我execu來自Eclipse的te mvn clean site
,它工作得很好。使用默認的config/sun_checks.xml
而不是看到1000多個checkstyle錯誤,我只得到27個checkstyle錯誤。
當我在Jenkins運行它時,出於某種原因,它沒有選擇我自定義的checkstyle規則。我得到了Jenkins的1000多個checkstyle錯誤。我檢查了「控制檯輸出」日誌,我沒有看到任何關於checkstyle的錯誤/警告。從詹金斯的執行行家命令是這樣的: -
<===[HUDSON REMOTING CAPACITY]===>channel started
Executing Maven: -B -f D:\hudson\jobs\test\workspace\pom.xml clean site
[INFO] Scanning for projects...
...
我希望能夠添加-e
或-X
選項看到一個更強大的日誌,但我不能找到將其插入到一個地方詹金斯。
如何讓我的自定義檢查式規則與哈德遜/詹金斯一起工作?
非常感謝。