androidjenkinsandroid-lint

Display Android Lint results in Jenkins


How can I display the results from Android Lint in Jenkins, e.g. as warnings? I want to browse the warnings from the Jenkins GUI, just like compiler warnings and PMD / Checkstyle warnings.

The output from the Jenkins job is something like this:

 [exec] 
 [exec] Scanning org.digitalcure.ccnf.app: ..........Incorrect detector reported disabled issue TooManyViews
 [exec] Incorrect detector reported disabled issue TooManyViews
 [exec] ...
 [exec] 
 [exec] Scanning org.digitalcure.android.common: ...
 [exec] res/values/strings.xml: Warning: The resource R.string.display_unit_abc appears to be unused [UnusedResources]
 [exec] res/values/strings.xml: Warning: The resource R.string.edit_error_abc appears to be unused [UnusedResources]
 [exec] Warning: Missing density variation folders in res: drawable-xhdpi [IconMissingDensityFolder]
 [exec] 
 [exec] 0 errors, 3 warnings

Android Lint can create a XML file too, but I'm afraid that there is no Jenkins plugin able to parse the file. Or am I missing something?


Solution

  • Pavol, thank you very much for your inspiration! Unfortunately your regexp/script doesn't work for me, but it was a very good starting point for further investigations. Here is what works for my configuration:

    Name: Android Lint Parser

    Regexp: ([^\s]*: )?([^ ]*):\s+(.*)\[(.*)\]$

    Groovy script:

    import hudson.plugins.warnings.parser.Warning;
    import hudson.plugins.analysis.util.model.Priority;
    
    String fileName = matcher.group(1);
    String lineNumber = "";
    String priority = matcher.group(2);
    String message = matcher.group(3);
    String category = matcher.group(4);
    
    if (fileName == null) {
      fileName = "(no file)";
    } else {
      int idx =  fileName.indexOf(':');
      if (idx > -1) {
        lineNumber = fileName.substring(idx + 1, fileName.size());
        fileName = fileName.substring(0, idx);
    
        int idx2 = lineNumber.indexOf(':');
        if (idx2 > -1) {
          lineNumber = lineNumber.substring(0, idx2);
        }
    
        idx2 = lineNumber.indexOf(' ');
        if (idx2 > -1) {
          lineNumber = lineNumber.substring(0, idx2);
        }
      }
    }
    
    return new Warning(fileName, lineNumber.size() > 0 ? Integer.parseInt(lineNumber) : 0, "Android Lint Parser", category, message, priority.equals("Error") ? Priority.HIGH : Priority.NORMAL);