首先,我们先在jenkins上新建一个item:
[img]http://dl2.iteye.com/upload/attachment/0110/9390/02d25777-20df-3971-9215-4de644085829.png[/img]
然后,就给项目命名和选择项目类型:
[img]http://dl2.iteye.com/upload/attachment/0110/9392/5b485454-edbf-30c5-af60-457e9748b81c.png[/img]
点击[OK]之后,就到了如下页面:
[img]http://dl2.iteye.com/upload/attachment/0110/9400/04987384-75a5-339a-9fee-6c2c157100d9.png[/img]
[img]http://dl2.iteye.com/upload/attachment/0110/9402/74cb23de-12bd-3733-866f-fc00a2bd8ada.png[/img]
[img]http://dl2.iteye.com/upload/attachment/0110/9404/2288db05-4d04-3258-8786-f7cf6c9a2db8.png[/img]
save完之后,项目就新建好了。
接下来讲讲配置checkstyle,要支持checkstyle就要在pom文件里添加checkstyle的支持。
先看一下pom.xml
这样子就可以支持mvn checkstyle:checkstyle命令了
指定checkstyle 文件的位置有两种方式。
第一种就是刚刚在上面的pom.xml中提到的。
必须把文件的配置放在<build>元素里面。参考阅读:[url]http://stackoverflow.com/questions/8975096/maven-checkstyle-configlocation-ignored[/url]
并且fcm-cs-check.xml 必须要跟pom.xml是同一层目录的。
如下图:
[img]http://dl2.iteye.com/upload/attachment/0110/9410/5c7354e0-48b4-3678-be70-4dfc4329bc19.png[/img]
这样子就可以report出checkstyle了。
第二种方法是:
在mvn 命令中指定checkstyle.config.location,参考:[url]https://dustplanet.de/howto-use-your-own-checkstyle-rules-in-your-jenkinsmaven-job/[/url]
两种方式只要支持一种就可以了。
贴最后一张成果图:
[img]http://dl2.iteye.com/upload/attachment/0110/9418/13156eb5-06f2-3f7b-acb0-89dd7214be90.png[/img]
--EOF--
[img]http://dl2.iteye.com/upload/attachment/0110/9390/02d25777-20df-3971-9215-4de644085829.png[/img]
然后,就给项目命名和选择项目类型:
[img]http://dl2.iteye.com/upload/attachment/0110/9392/5b485454-edbf-30c5-af60-457e9748b81c.png[/img]
点击[OK]之后,就到了如下页面:
[img]http://dl2.iteye.com/upload/attachment/0110/9400/04987384-75a5-339a-9fee-6c2c157100d9.png[/img]
[img]http://dl2.iteye.com/upload/attachment/0110/9402/74cb23de-12bd-3733-866f-fc00a2bd8ada.png[/img]
[img]http://dl2.iteye.com/upload/attachment/0110/9404/2288db05-4d04-3258-8786-f7cf6c9a2db8.png[/img]
save完之后,项目就新建好了。
接下来讲讲配置checkstyle,要支持checkstyle就要在pom文件里添加checkstyle的支持。
先看一下pom.xml
<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>css</groupId>
<artifactId>hw</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>hw</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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.16</version>
<configuration>
<consoleOutput>false</consoleOutput>
<outputFileFormat>xml</outputFileFormat>
<configLocation>fcm-cs-check.xml</configLocation>
<linkXRef>false</linkXRef>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>6.9</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
这样子就可以支持mvn checkstyle:checkstyle命令了
指定checkstyle 文件的位置有两种方式。
第一种就是刚刚在上面的pom.xml中提到的。
<configLocation>fcm-cs-check.xml</configLocation>
必须把文件的配置放在<build>元素里面。参考阅读:[url]http://stackoverflow.com/questions/8975096/maven-checkstyle-configlocation-ignored[/url]
并且fcm-cs-check.xml 必须要跟pom.xml是同一层目录的。
如下图:
[img]http://dl2.iteye.com/upload/attachment/0110/9410/5c7354e0-48b4-3678-be70-4dfc4329bc19.png[/img]
这样子就可以report出checkstyle了。
第二种方法是:
在mvn 命令中指定checkstyle.config.location,参考:[url]https://dustplanet.de/howto-use-your-own-checkstyle-rules-in-your-jenkinsmaven-job/[/url]
两种方式只要支持一种就可以了。
贴最后一张成果图:
[img]http://dl2.iteye.com/upload/attachment/0110/9418/13156eb5-06f2-3f7b-acb0-89dd7214be90.png[/img]
--EOF--