Display Android Lint Results in Jenkins

How can I display the results from Android Lint in Jenkins, for example. how are the warnings? I want to view warnings from the Jenkins GUI, just like compiler warnings and PMD / Checkstyle warnings.

The result of Jenkins looks 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 also create an XML file, but I'm afraid there is no Jenkins plugin capable of parsing the file. Or am I missing something?

+5
source share
3 answers

Pavol, thank you very much for your inspiration! Unfortunately, your regexp / script does not work for me, but it was a very good starting point for further research. 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);
+3

Jenkins Android Lint Plugin, SDK Tools r17 .

Lint XML , Jenkins.

+7

In compiling warning plugins from some version, you can create a parser from the jenkins configuration site using regexp and groovy script. I created one for lint, which I run as a shell script with output to some file.

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 = ""; //matcher.group(1)
String priority = matcher.group(2)
String message = matcher.group(3)
String category = matcher.group(4)
int idx =  fileName.indexOf(':');
if (idx > -1) {
  lineNumber = fileName.substring(idx+1,fileName.size());
  fileName = fileName.substring(0,idx);
}

return new Warning(fileName, lineNumber.size() > 0 ? Integer.parseInt(lineNumber) : 0, "Android Lint Parser", category, message, priority.equals("Error") ? Priority.HIGH : Priority.NORMAL);
0
source

All Articles