java
  • maven
  • jenkins
  • jenkins-plugins
  • checkstyle
  • 2017-05-30 345 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命令使用该配置。

    相关问题