File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,28 @@ def failurePatterns = [
2020 [pattern : / cat: .* No such file or directory/ , description : " GPU not found" ],
2121]
2222
23+ // Given a pattern, check if the log contains the pattern and return the context.
24+ def checkForPattern (pattern , log ) {
25+ def lines = log. split(' \n ' )
26+ for (int i = 0 ; i < lines. size(); i++ ) {
27+ if (lines[i] =~ pattern) {
28+ echo " Found pattern match in log for ${ pattern} "
29+
30+ // Get the two lines before and after failure.
31+ def contextStart = Math . max(0 , i - 2 )
32+ def contextEnd = Math . min(lines. size() - 1 , i + 2 )
33+ def contextLines = []
34+ for (int j = contextStart; j <= contextEnd; j++ ) {
35+ contextLines. add(lines[j])
36+ }
37+
38+ return [found : true , matchedLine : lines[i], context : contextLines. join(' \n ' )]
39+ }
40+ }
41+ echo " No pattern match found in log for ${ pattern} "
42+ return [found : false , matchedLine : " " , context : " " ]
43+ }
44+
2345class Version {
2446 int major, minor, patch
2547 @Override
You can’t perform that action at this time.
0 commit comments