简体   繁体   中英

Jenkins Build Failure Analyzer plugin regex multiline

I am using the Jenkins Build Failure Analyzer plugin trying to match a multiline pattern in the build log. The text I want to match in the log is:

Total time: 1 minute 45 seconds
Build step 'Invoke Ant' marked build as failure

The regex I am using is:

(?s)Total(.*)failure

Seems pretty simple, but this is not matching the lines above.

Another example I am working with is:

     [java] ACTION REQUIRED
     [java] 
     [java] I want to match this line
     [java] as well as this line
     [java] 
     [java] CONSOLE LOG

The regex for this is:

(?s)REQUIRED(.*)CONSOLE

Also produces no results.

I'm guessing that the log contains further text, even if it's whitespace (or newlines).

Remember, the plugin uses Pattern.match() so it has to match the entire "line". So perhaps try:

(?s)Total(.*)failure.*

To be a little more specific, you could do end with \\s* to just match trailing whitespace:

(?s)Total(.*)failure\s*

The Build Analyzer Plugin uses Pattern.match against single lines - you're attempting to match a multiline string.

From the wiki page :

The Build Log Indication searches through the build log, one line at a time, for a regular expression.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM