Regular Expression to use to parse warnings for continuous integration tool like Jenkins

225 views
Skip to first unread message

Dave

unread,
Mar 31, 2013, 6:28:09 PM3/31/13
to bndtool...@googlegroups.com
I've finally upgraded to using BND 2.0 (now 2.1) and I like that there are several more warnings displayed when building a bundle (through Ant anyways).  I use Jenkins for continuous integration so I'm trying to come up with a parser for all my BND warnings now so I can track them in Jenkins using the Compiler Warnings plug-in.  The plug-in needs a regular expression and a groovy script.  This is what I have right now, but it is missing file, line and other info:

Regular Expression: "\s\[bnd\]  (.*)"

Groovy Script:

import hudson.plugins.warnings.parser.Warning

String severity = "unknown"
String fileName = "unknown"
String lineNumber = "unknown"
String category = "unknown"
String message = matcher.group(1)

return new Warning(fileName, 1, "Dynamic Parser", category, message);


For other compiler output I've parsed, the file name and line number have been on the same line as the warning so it is fairly easy to do.  I'm not a regex expert, but maybe there is a way to pick up this information from the output.  Or maybe the output could be changed to include more info for each warning?

Thanks,
Dave

jerome moliere

unread,
Mar 31, 2013, 9:04:18 PM3/31/13
to bndtool...@googlegroups.com
Hi Dave,
could you post a short excerpt from the ouput you want to parse. We may try to improve your regex ... Or do you mean that the information is not present at all ?
Did you try to increase bnd verbose using the verbose attribute inside your ANT script ?
Kind regards
jerome

J.MOLIERE - Mentor/J



2013/4/1 Dave <dhum...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dave

unread,
Mar 31, 2013, 10:13:40 PM3/31/13
to bndtool...@googlegroups.com
I have not tried running in verbose mode yet, I can try that. but here is an example output:

      [bnd] # addAll 'bin' with ;,
      [bnd] # addAll 'x.y.z.core.bnd' with ,
      [bnd] Warnings
      [bnd]  Imports that lack version ranges: [com.google.protobuf, javax.xml.bind, javax.xml.bind.annotation, javax.xml.bind.annotation.adapters, javax.xml.datatype, org.osgi.framework, org.osgi.service.cm, org.osgi.service.component, org.osgi.service.event, org.osgi.service.log, org.osgi.service.metatype]
      [bnd]  Used bundle version 1.16 for exported package x.y.z.core
      [bnd]  Used bundle version 1.16 for exported package x.y.z.core.asset.capability.proto
      [bnd] # x.y.z.core (x.y.z.core-api.jar) 1601 

As you can see the bnd filename is at the top of the output, but the warnings are listed out line by line.  I'm trying to treat each line as a separate warning, so I can track the warnings over time and to know when a new one comes up.  For Jenkins, I would need a regular expression that finds each warning (each line in the output), but also contains the filename (at least).  I don't see the line number in the output at all, so I'm going that isn't possible to log.

For instance, here is an example of output I use for our Jade parsing tool that I can easily write a regex for:

[JadeGenerator.py] WARNING: assetDirectoryServiceMessages.proto@25: Enum type "Activated" does not have a matching data type.
[JadeGenerator.py] WARNING: assetDirectoryServiceMessages.proto@28: Enum type "Activating" does not have a matching data type.
[JadeGenerator.py] WARNING: assetDirectoryServiceMessages.proto@31: Enum type "Deactivated" does not have a matching data type.

Each line contains the file and the line number making it easy to log the warning in Jenkins.
Reply all
Reply to author
Forward
0 new messages