java
  • maven
  • jenkins
  • jenkins-plugins
  • checkstyle
  • 2017-05-30 336 views 0 likes 
    0

    我試圖從默認的checkstyle配置sun-check切換到谷歌檢查。如何在Jenkins中爲Java配置Checkstyle配置

    在我jenkinsfile,我正在寫:

    stage('checkstyle') { 
          steps { 
           sh "mvn clean checkstyle:checkstyle -Dcheckstyle.config.location='https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml'" 
           checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'target/checkstyle-result.xml', unHealthy: '' 
          } 
         } 
    

    這是與錯誤信息未能

    未能執行目標 org.apache.maven.plugins:Maven的checkstyle-插件:2.17:項目pmm上的checkstyle (default-cli):Checkstyle中發生錯誤 報告生成:checkstyle執行期間失敗: 期間失敗checkstyle配置:無法解析配置am - 元素類型「html」必須聲明。:8:17 - > [Help 1]

    如何更改Jenkins的checkstyle配置?

    回答

    1

    https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml

    首先,你給它一個HTML文檔不是XML文件。您必須使用該URL到github的原始文件。

    例子:https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml

    其次,你不應該使用google_checks的在線快照版本。瞭解原因,請參閱https://stackoverflow.com/a/44060396/1016482

    如何更改Jenkins的checkstyle配置?

    提取在checkstyle JAR中找到的配置(如果您要更改它),並讓您的maven命令使用該配置。

    相關問題