Class PipelineLogExtractor

java.lang.Object
io.jenkins.plugins.explain_error.PipelineLogExtractor

public class PipelineLogExtractor extends Object
Utility for extracting log lines related to a failing build or pipeline step and computing a URL that points back to the error source.

For WorkflowRun (Pipeline) builds, this class walks the flow graph to locate the node that originally threw the error, reads a limited number of log lines from that step, and records a node-specific URL that can be used to navigate to the failure location. When no failing step log can be found, or when the build is not a pipeline, it falls back to the standard build console log.

If the optional pipeline-graph-view plugin is installed, the generated URL is compatible with its overview page so that consumers can deep-link directly into the failing node from error explanations.

  • Field Details

  • Constructor Details

    • PipelineLogExtractor

      public PipelineLogExtractor(Run<?,?> run, int maxLines)
  • Method Details

    • getFailedStepLog

      public List<String> getFailedStepLog() throws IOException
      Extracts the log output of the specific step that caused the pipeline failure.
      Returns:
      A non-null list of log lines for the failed step, or the overall build log if no failed step with a log is found.
      Throws:
      IOException - if there is an error reading the build logs.
    • getUrl

      public String getUrl()
      Returns the URL associated with the extracted log.

      When getFailedStepLog() finds a failed pipeline step with an attached log and the pipeline-graph-view plugin is available, this will point to the pipeline overview page with the failing node preselected. Otherwise, it falls back to the build's console output URL.

      Returns:
      the Jenkins URL for either the pipeline overview of the failing step or the build console output, or null if getFailedStepLog() has not been invoked successfully.