Introduction – Nikita Pandey from Oriental Institute of Science & Technology, Bhopal

Hello Sir,

I reviewed the Moonshot API docs and the copyartifact-plugin structure.
The direction I’m taking is intercepting build failure events, then collecting logs and artifacts, then feeding them to the Moonshot model via the Gerrit ChatGPT plugin, and then returning summarized root causes and fix suggestions.
I will send you the architecture draft soon.

Hi @Nik

I don’t know if this should be ok for returning the message as @mawinter69 explain when suggest to give back the error over a string. Then this can be used to send by slack, mattermost, email…

diff --git a/src/main/java/io/jenkins/plugins/explain_error/ErrorExplainer.java b/src/main/java/io/jenkins/plugins/explain_error/ErrorExplainer.java
index 4783c5b..38a1e94 100644
--- a/src/main/java/io/jenkins/plugins/explain_error/ErrorExplainer.java
+++ b/src/main/java/io/jenkins/plugins/explain_error/ErrorExplainer.java
@@ -24,14 +24,14 @@ public class ErrorExplainer {
         return providerName;
     }
 
-    public void explainError(Run<?, ?> run, TaskListener listener, String logPattern, int maxLines) {
+    public String explainError(Run<?, ?> run, TaskListener listener, String logPattern, int maxLines) {
         String jobInfo = run != null ? ("[" + run.getParent().getFullName() + " #" + run.getNumber() + "]") : "[unknown]";
         try {
             GlobalConfigurationImpl config = GlobalConfigurationImpl.get();
 
             if (!config.isEnableExplanation()) {
                 listener.getLogger().println("AI error explanation is disabled in global configuration.");
-                return;
+                return null;
             }
 
             BaseAIProvider provider = config.getAiProvider();
@@ -47,6 +47,7 @@ public class ErrorExplainer {
                 // Store explanation in build action
                 ErrorExplanationAction action = new ErrorExplanationAction(explanation, errorLogs, provider.getProviderName());
                 run.addOrReplaceAction(action);
+                return explanation;
             } catch (ExplanationException ee) {
                 listener.getLogger().println(ee.getMessage());
             }
@@ -57,6 +58,7 @@ public class ErrorExplainer {
             LOGGER.severe(jobInfo + " Failed to explain error: " + e.getMessage());
             listener.getLogger().println(jobInfo + " Failed to explain error: " + e.getMessage());
         }
+        return null;
     }
 
     private String extractErrorLogs(Run<?, ?> run, String logPattern, int maxLines) throws IOException {
diff --git a/src/main/java/io/jenkins/plugins/explain_error/ExplainErrorStep.java b/src/main/java/io/jenkins/plugins/explain_error/ExplainErrorStep.java
index cea9ec3..58c8f19 100644
--- a/src/main/java/io/jenkins/plugins/explain_error/ExplainErrorStep.java
+++ b/src/main/java/io/jenkins/plugins/explain_error/ExplainErrorStep.java
@@ -68,7 +68,7 @@ public class ExplainErrorStep extends Step {
         }
     }
 
-    private static class ExplainErrorStepExecution extends SynchronousNonBlockingStepExecution<Void> {
+    private static class ExplainErrorStepExecution extends SynchronousNonBlockingStepExecution<String> {
 
         private static final long serialVersionUID = 1L;
         private final transient ExplainErrorStep step;
@@ -79,14 +79,12 @@ public class ExplainErrorStep extends Step {
         }
 
         @Override
-        protected Void run() throws Exception {
+        protected String run() throws Exception {
             Run<?, ?> run = getContext().get(Run.class);
             TaskListener listener = getContext().get(TaskListener.class);
 
             ErrorExplainer explainer = new ErrorExplainer();
-            explainer.explainError(run, listener, step.getLogPattern(), step.getMaxLines());
-
-            return null;
+            return explainer.explainError(run, listener, step.getLogPattern(), step.getMaxLines());
         }
     }
 }

Hi @panicking and @mawinter69, I’ve rebased this PR Add line number extraction capability for error explanation by Nikitaa104 · Pull Request #59 · jenkinsci/explain-error-plugin · GitHub on the latest upstream/main to include recent changes.

:white_check_mark: Successfully merged with upstream

:white_check_mark: Plugin builds cleanly

:white_check_mark: Line number extraction feature remains intact

:white_check_mark: All previous review feedback addressed.

The PR is ready for final review. Please let me know if any additional changes are needed.

Thank you!