Sun
Sun

Reputation: 3564

Checkstyle working in Maven, but not working in Jenkins

I am using Maven, Maven checkstyle plugin, Jenkins and Jenkins checkstyle plugin.

I have 7 projects total. 1 parent and 6 child projects.

I have the following 3 scenarios :

  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.

What I mean by 'not working in Jenkins' is that I installed checkstyle plugin in Jenkins, In the Jenkins job i selected 'Publish Checkstyle analysis results' check box. In scenario-1 i am able to see the checkstyle link in the jenkins job page. And if i click on that all code violations reports are appearing. In other scenarios (2,3) the Checkstyle link also not appearing.

Upvotes: 4

Views: 4066

Answers (1)

Flipbed
Flipbed

Reputation: 720

Just found the solution.

In the project configure menu, in the "Goals and options" field you need to add 'site' without the ' characters. In my "Goals and options" field I had: clean install. This did not run checkstyle. But then I changed it to: clean install site. And now checkstyle runs!

Hope this solves your problem.

Edit:

My pom.xml has been extended with the tag:

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

to run checkstyle. Try using only that for checkstyle and then run the project again.

Upvotes: 2

Related Questions