Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
private static final Logger LOGGER = Logger.getLogger(ErrorExplainer.class.getName());

public void explainError(Run<?, ?> run, TaskListener listener, String logPattern, int maxLines) {
String jobInfo = run != null ? ("[" + run.getParent().getFullName() + " #" + run.getNumber() + "]") : "[unknown]";

Check warning on line 19 in src/main/java/io/jenkins/plugins/explain_error/ErrorExplainer.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 19 is only partially covered, one branch is missing
try {
GlobalConfigurationImpl config = GlobalConfigurationImpl.get();

Expand All @@ -41,16 +42,17 @@
// Get AI explanation
AIService aiService = new AIService(config);
String explanation = aiService.explainError(errorLogs);
LOGGER.info(jobInfo + " AI error explanation succeeded.");

// Store explanation in build action
ErrorExplanationAction action = new ErrorExplanationAction(explanation, errorLogs);
run.addOrReplaceAction(action);

// Explanation is now available on the job page, no need to clutter console output

} catch (Exception e) {
LOGGER.severe("Failed to explain error: " + e.getMessage());
listener.getLogger().println("Failed to explain error: " + e.getMessage());
LOGGER.severe(jobInfo + " Failed to explain error: " + e.getMessage());
listener.getLogger().println(jobInfo + " Failed to explain error: " + e.getMessage());

Check warning on line 55 in src/main/java/io/jenkins/plugins/explain_error/ErrorExplainer.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 45-55 are not covered by tests
}
}

Expand Down Expand Up @@ -79,7 +81,8 @@
* Used for console output error explanation.
*/
public String explainErrorText(String errorText, Run<?, ?> run) {

String jobInfo = run != null ? ("[" + run.getParent().getFullName() + " #" + run.getNumber() + "]") : "[unknown]";

Check warning on line 84 in src/main/java/io/jenkins/plugins/explain_error/ErrorExplainer.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 84 is only partially covered, one branch is missing

try {
GlobalConfigurationImpl config = GlobalConfigurationImpl.get();

Expand All @@ -101,13 +104,12 @@
// Get AI explanation
AIService aiService = new AIService(config);
String explanation = aiService.explainError(errorText);

LOGGER.info(jobInfo + " AI error explanation succeeded.");
LOGGER.fine("Explanation length: " + (explanation != null ? explanation.length() : 0));

return explanation;

} catch (Exception e) {
LOGGER.severe("Failed to explain error text: " + e.getMessage());
LOGGER.severe(jobInfo + " Failed to explain error text: " + e.getMessage());

Check warning on line 112 in src/main/java/io/jenkins/plugins/explain_error/ErrorExplainer.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 112 is not covered by tests
e.printStackTrace();
return "Failed to explain error: " + e.getMessage();
}
Expand Down