Class IncidentItem

java.lang.Object
io.jenkins.plugins.batchcontrol.action.IncidentItem
All Implemented Interfaces:
ModelObject

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public class IncidentItem extends Object implements ModelObject
One incident at /batch-control/incidents/<id>/ (SPEC item 11): detail view plus the four state-changing POST endpoints (acknowledge, resolve, comment, rerun).

Every endpoint is @RequirePOST (GET never changes state) and performs its permission check before delegating. All business rules (the OPEN → ACKNOWLEDGED → RESOLVED state machine, comment recording, rerun request creation and linking) are enforced by IncidentService — this class contains zero state logic.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    doAcknowledge(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String comment)
    POST acknowledge?comment=... — OPEN → ACKNOWLEDGED.
    void
    doComment(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String comment)
    POST comment?comment=... — adds a comment without a status change.
    void
    doRerun(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp)
    POST rerun with the repeated approvers field (the single approver field the rerun form posts is read too) — creates a rerun RunRequest carrying the failed run's own parameter values and linked back to this incident, then redirects to the new request's detail page.
    void
    doResolve(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String comment)
    POST resolve?comment=... — ACKNOWLEDGED → RESOLVED.
    format(Instant instant)
    Jelly helper: human-readable timestamp.
    The refusal of form form on this request, or an empty one (DEF-09, Jelly).
    Approver candidates for the rerun request form (global list ∩ job restriction).
    Incident creation time (first transition).
     
     
     
    e2e-04 UX-19: the job's URL for a viewer who may read it (P-09, findJob()), else null.
    Link predicates: a link to another screen is rendered only if the user may open it.
    The stored console log excerpt as one string for the <pre> block.
    Root-relative build URL for the resolving run, or null (same rule as getRunUrl()).
    Root-relative build URL for the originating run; null (plain text) when the id is malformed or the viewer lacks Item/Read on the job (D-44, Visibility.runUrlFromRunId(java.lang.String)).
    Permissions for this screen's l:layout (the same set its section gate checks).
    boolean
    View gating only; the service re-validates the state machine.
    boolean
    Comments stay possible in every state (SPEC section 4: RESOLVED still takes comments).
    boolean
    View gating for the rerun form (e2e-03 DEF-12): BatchControl/Request and Item/Read on the incident's job, the permissions a run request needs (D-38a; Item/Build is not required).
    boolean
    View gating only; the service re-validates the state machine.
    boolean
    Whether the incident's job still exists and is visible, so a rerun is possible at all.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getIncident

      public Incident getIncident()
    • getId

      public String getId()
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface ModelObject
    • format

      public String format(Instant instant)
      Jelly helper: human-readable timestamp.
    • getRunUrl

      @CheckForNull public String getRunUrl()
      Root-relative build URL for the originating run; null (plain text) when the id is malformed or the viewer lacks Item/Read on the job (D-44, Visibility.runUrlFromRunId(java.lang.String)).
    • getResolvedByRunUrl

      @CheckForNull public String getResolvedByRunUrl()
      Root-relative build URL for the resolving run, or null (same rule as getRunUrl()).
    • getCreatedAt

      @CheckForNull public Instant getCreatedAt()
      Incident creation time (first transition).
    • getLogTailText

      public String getLogTailText()
      The stored console log excerpt as one string for the <pre> block. The Jelly default escaping renders it as inert text; secrets were masked at capture time (D-19).
    • getApproverOptions

      public List<String> getApproverOptions()
      Approver candidates for the rerun request form (global list ∩ job restriction).
    • isCanAcknowledge

      public boolean isCanAcknowledge()
      View gating only; the service re-validates the state machine.
    • isCanResolve

      public boolean isCanResolve()
      View gating only; the service re-validates the state machine.
    • isCanComment

      public boolean isCanComment()
      Comments stay possible in every state (SPEC section 4: RESOLVED still takes comments).
    • isCanRerun

      public boolean isCanRerun()
      View gating for the rerun form (e2e-03 DEF-12): BatchControl/Request and Item/Read on the incident's job, the permissions a run request needs (D-38a; Item/Build is not required). A user without BatchControl/Request is not offered the form. The endpoint and the service re-check.
    • isJobAvailable

      public boolean isJobAvailable()
      Whether the incident's job still exists and is visible, so a rerun is possible at all.
    • getJobUrl

      public String getJobUrl()
      e2e-04 UX-19: the job's URL for a viewer who may read it (P-09, findJob()), else null. Its run request form is <url>batch-control/; the view links that form only together with isCanRerun(), the same Request + Item/Read test the form itself applies (D-38a).
    • formErrors

      public FormErrors formErrors(String form)
      The refusal of form form on this request, or an empty one (DEF-09, Jelly).
    • getViewPermissions

      public Permission[] getViewPermissions()
      Permissions for this screen's l:layout (the same set its section gate checks).
    • getLinks

      public SectionAccess getLinks()
      Link predicates: a link to another screen is rendered only if the user may open it.
    • doAcknowledge

      public void doAcknowledge(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter String comment) throws IOException, jakarta.servlet.ServletException
      POST acknowledge?comment=... — OPEN → ACKNOWLEDGED.
      Throws:
      IOException
      jakarta.servlet.ServletException
    • doResolve

      public void doResolve(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter String comment) throws IOException, jakarta.servlet.ServletException
      POST resolve?comment=... — ACKNOWLEDGED → RESOLVED.
      Throws:
      IOException
      jakarta.servlet.ServletException
    • doComment

      public void doComment(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter String comment) throws IOException, jakarta.servlet.ServletException
      POST comment?comment=... — adds a comment without a status change.
      Throws:
      IOException
      jakarta.servlet.ServletException
    • doRerun

      public void doRerun(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException
      POST rerun with the repeated approvers field (the single approver field the rerun form posts is read too) — creates a rerun RunRequest carrying the failed run's own parameter values and linked back to this incident, then redirects to the new request's detail page.

      D-72 (SPEC item 11): when a value of the failed run cannot be recovered (RerunNeedsFormException: a stashed file the build has cleared, a deleted build) no request is created; the answer is a 302 to the job's Request Run form, <job>/batch-control/?p.<name>=<value>...&fromRerun=<incident id>, carrying the recoverable non-sensitive values within the prefill caps (RequestRunPrefill.rerunQuery(hudson.model.Job<?, ?>, java.util.Map<java.lang.String, java.lang.String>, java.lang.String)); the form says that file and password values must be provided again.

      Throws:
      IOException
      jakarta.servlet.ServletException