regexjenkinslogginggroovymultiline

Multi-line Regular Expression in Groovy not matching


I am struggling constructing a multi-line matching regular expression in Groovy.

Given following log:

12:42:44,914 ma# ERROR [a.o.k.b.p.A] ********************* Es folgen aggregierte Fehler *********************

12:42:44,915 ma# ERROR [a.o.k.b.p.A] at.java.lang.NullPointerException
    at a.o.k.b.s.AbstractSvc.buildFinalException(AbstractSvc.java:236)
(in 2 Items, z.B. 1114/00347, 1114/00537)

12:42:44,916 ma# ERROR [a.o.k.b.p.A] HTTP 400
(in 2 Items, z.B. 1128/01634, 1128/02616)

12:42:44,916 ma# ERROR [a.o.k.b.p.A] >>>>> 50 Polizzen polizziert, davon 4 Polizzen fehlerhaft mit 2 verschiedenen Fehler!

I want ideally to extract all lines between the first and last.

I am trying to access the Jenkins log via

    def logMatcher = manager.getLogMatcher('(?s).*aggregierte(.*)Polizzen polizziert.*')
    if (logMatcher?.matches()) {
        def result = logMatcher.group(1)
        manager.addWarningBadge(result)
    }

I would expect it would give me a rough match (including parts of the first and last line), but it will not run in the if block.

What am I doing wrong here? My tests on regex101.com showed that this should work. On Jenkins, it will only match if it is within one line, e.g. regex ".Es (.) aggregierte Fehler.*"


Solution

  • The problem is that JenkinĀ“s goovy-postbuild-plugin limits to single lines as daggett commented on my question.