简体   繁体   中英

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, eg regex ". Es (. ) aggregierte Fehler.*"

问题是詹金的 goovy-postbuild-plugin 限制为单行,因为 daggett 对我的问题发表了评论。

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