From df90bcbfd0f7180b4e7d61ef1a38c9d096f4084f Mon Sep 17 00:00:00 2001 From: andrew clark Date: Wed, 29 Oct 2025 08:19:56 -0600 Subject: [PATCH] Added failure pattern check (#3111) [ROCm/composable_kernel commit: aa22da07be29ccc7c1e389c09f4dad6c155be1d6] --- Jenkinsfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 625b6d0d09..98ca17a571 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,6 +20,28 @@ def failurePatterns = [ [pattern: /cat: .* No such file or directory/, description: "GPU not found"], ] +// Given a pattern, check if the log contains the pattern and return the context. +def checkForPattern(pattern, log) { + def lines = log.split('\n') + for (int i = 0; i < lines.size(); i++) { + if (lines[i] =~ pattern) { + echo "Found pattern match in log for ${pattern}" + + // Get the two lines before and after failure. + def contextStart = Math.max(0, i - 2) + def contextEnd = Math.min(lines.size() - 1, i + 2) + def contextLines = [] + for (int j = contextStart; j <= contextEnd; j++) { + contextLines.add(lines[j]) + } + + return [found: true, matchedLine: lines[i], context: contextLines.join('\n')] + } + } + echo "No pattern match found in log for ${pattern}" + return [found: false, matchedLine: "", context: ""] +} + class Version { int major, minor, patch @Override