Skip to content

Commit a751e92

Browse files
committed
wip
1 parent 3670ed8 commit a751e92

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

libraries/Jenkins/jenkins.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,32 @@ def analyze_logs(self, logs: str, error_patterns_file: str = None):
469469

470470
# Use default suggestion if no specific issues found
471471
if not suggestions:
472-
suggestions.append({"suggestion": "Check detailed logs for root cause.", "log": logs})
472+
# Find all error/failure lines with context (5 lines before and after)
473+
error_blocks = []
474+
for match in re.finditer(r'.*\b(error|failure)\b.*', normalized_logs, re.MULTILINE | re.IGNORECASE):
475+
start = max(0, match.start() - 500) # Get 500 chars before for context
476+
end = min(len(normalized_logs), match.end() + 500) # Get 500 chars after for context
477+
error_blocks.append(normalized_logs[start:end])
478+
479+
if error_blocks:
480+
# Deduplicate while preserving order
481+
unique_errors = []
482+
seen = set()
483+
for block in error_blocks:
484+
if block not in seen:
485+
seen.add(block)
486+
unique_errors.append(block)
487+
488+
suggestions.append({
489+
"suggestion": "Check detailed logs for root cause.",
490+
"log": "\n---\n".join(unique_errors)
491+
})
492+
else:
493+
# Provide more specific guidance when no errors found
494+
suggestions.append({
495+
"suggestion": "Check detailed logs for root cause.",
496+
"log": logs
497+
})
473498

474499
return suggestions
475500

0 commit comments

Comments
 (0)