2013-09-22 81 views
3

我正在使用Maven,Maven checkstyle插件,Jenkins和Jenkins checkstyle插件。Checkstyle在Maven工作,但不在Jenkins工作

我總共有7個項目。 1個家長和6個兒童項目。

我有以下3種情況:

  1. 的Checkstyle報告所有project.n父POM我宣佈標籤的CheckStyle插件:

    • 我跑mvn clean site命令

    • 它在eclipse中與maven一起工作。並在詹金斯也。

    • 爲所有7個項目提供checkstyle報告。

  2. 除2個項目外的所有項目的Checkstyle報告。

    • 我在父POM刪除一部分,我加入

    • 我在剩下的4個項目加入,我宣佈標籤的CheckStyle插件。

    • 它在eclipse中工作,但不在Jenkins中工作。

    請給出解決方案

    我的代碼:

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

  • 我刪除的CheckStyle插件在父
  • 我添加了與上面的代碼相同的4個需要項目中的checkstyle插件。
  • 在剩下的2個孩子項目中,我加入了這個。

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

  • 我運行 '命令mvn乾淨的網站'

  • 它在Maven的工作如預期,但在詹金斯不工作。

我在'Jenkins'中不工作的意思是我在Jenkins中安裝了checkstyle插件,在Jenkins工作中我選中了'Publish Checkstyle analysis results'複選框。在場景1中,我能夠在jenkins作業頁面中看到checkstyle鏈接。如果我點擊所有代碼違規報告出現。在其他情況下(2,3)Checkstyle鏈接也沒有出現。

+0

我現在自己也有同樣的問題。我希望有人會給出答案! – Flipbed

回答

1

剛剛找到解決方案。

在項目配置菜單中的「目標和選項」字段中,您需要添加沒有'字符的'站點'。在我的「目標和選項」字段中,我有:乾淨的安裝。這沒有運行checkstyle。但後來我將它改爲:clean install site。現在checkstyle運行!

希望這可以解決您的問題。

編輯:

我的pom.xml已經擴展了標籤:

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

運行CheckStyle的。嘗試僅使用checkstyle,然後再次運行項目。

+0

對不起,我做了同樣的(乾淨安裝網站),但沒有結果。你能否提供一些更詳細的信息。 – Sun