Build failure conditions with Regex

I want to create a new regex condition so that the build will fail if the number of occurrences of the word "Warning:" exist in the build log more than a certain number (say 1000, it will reduce over time).

I cannot for the life of me get a regex to work, the most recent I have tried is this one that I believe should work:

(?:\\bWarning:.*?){1000,}

or a modified version to enable single line matching

(?s)(?:\\bWarning:.*?){1000,}
1 comment
Comment actions Permalink

Hi Craig

String matching is performed separatelly for each log message, not for the whole log. So regular expressions do not allow to count common mumber of string instances.

As alternate solution you can analise your project by IDEA or ReSharper inspections, and use Fail build on metric change option.

Michael

0

Please sign in to leave a comment.