Getting Checkstyle custom rule to work in Hudson/Jenkins

I'm having problems trying to get checkstyle to work properly in Hudson/Jenkins.

I created a custom checkstyle rule with very minimal rules in it (just to see if it works) and place it in some server:-

<?xml version="1.0"?> <!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" ""> <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>

I have a parent pom that looks like this:-

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="" xmlns:xsi="" xsi:schemaLocation=""> <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>

The actual project will include the parent pom, like this:-

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

When I execute mvn clean site from Eclipse, it works just fine. Instead of seeing 1000+ checkstyle errors using the default config/sun_checks.xml, I'm getting just 27 checkstyle errors.

When I run it in Jenkins, for some reason, it is not picking up my custom checkstyle rule. I'm getting 1000+ checkstyle errors from Jenkins. I checked the "Console Output" log and I'm not seeing any errors/warnings on checkstyle. The executed maven command from Jenkins look like this:-

<===[HUDSON REMOTING CAPACITY]===>channel started Executing Maven: -B -f D:\hudson\jobs\test\workspace\pom.xml clean site [INFO] Scanning for projects... ...

I'm hoping to be able to add -e or -X option to see a more robust log, but I can't find a place to insert them in Jenkins.

How do I get my custom checkstyle rule to work with Hudson/Jenkins?

Thanks much.

-------------Problems Reply------------

You can add the -eand -X switch in the "Goals und Optionen" field.

Are you refering checkstyle from an external location? If so, maybe you can try adding checkstyle to your project in your VCS (when this works it might be a network problem). Adding checkstyle.xml to your VCS also has the benefit, that you have reproducibility of your builds (and the other benifits VCS have to offer).

I setup how Maven finds my checkstyle.xml configLocation differently

maybe that'll get Jenkins working.

Also if you create a standard job instead of a maven job on Jenkins you can still execute a maven goal and you can simply add parameters







Written up here:

source code here:

Category:java Views:0 Time:2011-06-15

Related post

  • How to write custome rule for checkstyle in sonar 4.5.1? 2014-12-15

    I have upgraded from sonar 4.4 to 4.5.1, when i'm trying to import checkstyles, all the rules are not getting imported. i have reffered some information regarding this and came to know that we need to write custome rules. i tried to wrtie custom rule

  • Ease of writing custom rules in (Java) static code analysis tools 2011-04-15

    At present I am working for a group where source code (Java) for multiple projects have to be analysed by static code analysic tools But I would like to write custom rules that I can add to the existing set of rules provided by the tool (the rules wo

  • Creating a custom rule in FxCop 2008-12-14

    I want to create extra rules in FXCop. Custom Rules to help ensure specific best practices like checking against inline sql. I'm really looking for good resources and examples. Thanks! --------------Solutions------------- This tutorial seems really c

  • Can't see my custom rules with fxcop 2009-11-16

    I'm trying to develop a custom rule for fxcop. I've this code : namespace TestCustomRuleFxCop { public class DoTheRightThingRule : BaseIntrospectionRule { public DoTheRightThingRule() : base("DoTheRightThing", "TestCustomRuleFxCop.Rules", typeof(DoTh

  • fxcop custom rules - Avoid having more than one class per file 2009-11-23

    as fxcop is an assembly inspector, is it possible to create a custom rule that check if there's more than one class per file ? If yes, how to do that ? Thanks for your help --------------Solutions------------- It is not possible to do that. Since FxC

  • jQuery Validate Custom Rule Ignore a Checkbox 2009-12-10

    With some help from other post the related to validating multiple checkboxes, I decided to go with this customer rul $.validator.addMethod("checkBox", function(value, element) { return $("input[type=checkbox]:checked").length > 0; }, ""); I then c

  • How to validate DataReader is actually closed using FxCop custom rule? 2010-03-09

    I have written couple of custom rules in for FxCop 1.36. I have written code to find weather an opened DataReader is closed or not. But it does not check which DataReader object is calling the Close() method so I can't be sure if all opened DataReade

  • Custom Rules With PMD - Passing values to a rule at runtime 2010-07-31

    My requirement is to parse java files and find the classes or interfaces which implement a particular interface. Hence I started with implementing custom rules in PMD. I was able to write an XPath expression to search the classes & interfaces but

  • How can I walk the method call to an Action, Func, or Delegate in introspector for a custom rule? 2010-09-07

    I'm writing a custom rule to verify the constructor of any control type calls initialize component. But when I hit these 2 edge cases: public Form1(int? testInt,bool testBool,bool testBool2) : this(false) { Action init = ( ) => InitializeComponent

  • John the Ripper Custom Rule 2011-01-19

    I am using John the Ripper to crack a copy of the passwd file at my work. I want to alert users that have weak passwords. I happen to know that many accounts have the default password which is different for every user but matches a specific pattern.

  • StyleCop Custom Rules: Method Parameters and Variables 2011-06-28

    I am new to StyleCop, and I need to implement own coding standarts for the place I work. I am using VS2005 and cannot debug it. Upgrading to VS2008/2010 is not an option for us now. I wonder many things: 1) How can I identify the methods parameters?

  • jquery validate - custom rule - dependency callback 2011-07-27

    I really have no idea why my custom rule in jquery isnt working. all it is is looking for a substring in a text, making it required if it DOESNT appear, not required if it does. I am using the jquery validate library. I hope its something simple... p

  • jquery validation custom rule broken with ajax form 2011-08-06

    This rule worked when I was using a php form, but once I switched over to ajax, the rule is broken, while rules in the original jquery.validate.min.js rules (like checking email and credit card numbers) work. I have my custom rule stored in another f

  • Custom rules using Jquery Validate plugin 2011-08-23

    I've read all of the Jquery Validate documentation but I'm still not clear on how to have my own custom rules for validating inputs. HTML <form id="myForm"> <input type="text" name="firstName" class="required" /> <input type="text" nam

  • How to write a Checkstyle custom check involving indirect inheritance? 2011-10-14

    We need to write a checkstyle custom check that verifies a specific condition for classes that inherit—directly or indirectly—from a certain class A. Is it possible to identify the indirect inheritance using the checkstyle API? For example, suppose w

  • jquery validation. custom rules using selector syntax 2011-10-26

    I'm writing a system utilizing jQuery Validation that pulls in custom rules, messages via jSON and dynamically validates multiple forms in single pages. All is going swimmingly except I cannot find any decent information on the correct syntax for cus

  • jQuery validation plug-in warning-only custom rule 2011-11-08

    In the jQuery validation plug-in from bassistance, is it possible to define a custom rule which displays an error message but does not block the user from submitting the form? We have one particular field for which the software should give the user f

  • Resharper: Trying to create a custom rule / pattern where comments must start with a capital letter and end with a period 2011-12-06

    We just finished defining our coding standards in our group and I'd like to create some custom rules in Resharper to enforce said standards. Among them is enforcing that all comments start with a space, a capital letter and ends with a period. Are th

  • Set with custom rule 2012-04-14

    According to the Set doc, elements in a set are compared using eql?. I have a class like: class Foo attr_accessor :bar, :baz def initialize(bar = 1, baz = 2) @bar = bar @baz = baz end def eql?(foo) bar == && baz == foo.baz end end In

Copyright (C), All Rights Reserved.

processed in 0.096 (s). 11 q(s)