Jenkins——静态检查checkstyle自定义代码检查

  1. pom的配置
    a) 在里增加checkstyle配置,代码如下:
  
    org.apache.maven.plugins  
    maven-checkstyle-plugin  
    2.17
    
        ture
        xml
        eidlink_checks.xml
        ture
    

b) 在里增加checkstyle的报告生存配置,代码如下:


    org.apache.maven.plugins
    maven-checkstyle-plugin
    2.17
    
        checkstyle.xml
    

  1. 定义本公司checkstyle规则
    checkstyle默认使用sun_checks.xml或者google_checks.xml,规则定义比较严格,在实际使用中进行了取舍。






   

   
   
   

   
   
   
       
   

   
   
   

   
   
   

   
   
   
       
   

   
   
   
      
      
      
      
      
   

   
   
   
   
   
   

   
       

       
       
       
           
           
       
       
       
       


       
       
       
       
       
       
       
       
       
       
       


       
       
       
         
       
       


       
       
       
           
       
       
       


       
       
       
       
       
       
           
       
       
       
       
       
       
       
           
       


       
       
       
       


       
       
       
       
       
       
       


       
       
       
       
       
       
       
       
       
       
       
       

       
       
       
       
       
       
       


       
       
       
       
       
           
       
       
   

  1. jenkins配置
    a) 安装插件Checkstyle Plug-in
    b) 增加构建步骤clean install checkstyle:checkstyle


    Jenkins——静态检查checkstyle自定义代码检查_第1张图片
    Paste_Image.png

    c) 增加构建后步骤,默认设置


    Jenkins——静态检查checkstyle自定义代码检查_第2张图片
    Paste_Image.png
  2. 查看检查报告
    趋势图:
Jenkins——静态检查checkstyle自定义代码检查_第3张图片
Paste_Image.png

检查报告:

Jenkins——静态检查checkstyle自定义代码检查_第4张图片
Paste_Image.png

【参考】
1、Jenkins+maven+checkstyle对java代码进行静态代码分析
2、maven配置checkstyle检查的自定义模块

你可能感兴趣的:(Jenkins——静态检查checkstyle自定义代码检查)