Regex returns more matches than it should if errors are close together

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      Some of our tests return huge error files if the log file being parsed has matching errors that are closer together than the setting for "linesAfter". This is true even if "maxMatches" is set to just 1. Our setting in email-ext-plugin is:

       

      ${BUILD_LOG_REGEX, regex="(?m)^(nc\\w+:\\s+\\*E,|.\\bNG\\b|\\s*Error
      b|E-).
      $", linesBefore=5, linesAfter=10, maxMatches=5, showTruncatedLines=false
      }

       

      so this should limit the number of errors returned to 5. However, because the gap between matched errors is less than 10 lines this means that (in the Java code) the number of lines remaining to be written out gets reset to 10 on every subsequent match. The break condition for exiting the regex is the the number of lines remaining is 0 (amongst others) but this never happens for this case.

       

      This can be fixed by modifying BuildLogRegexContent.java on line 291. Change this line to:

      if (matched & (numMatches < maxMatches))

      and this will properly limit the number of matches to the value specified in numMatches and allow the regex to complete correctly.

            Assignee:
            Alex Earl
            Reporter:
            Richard Wilkinson
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: