Class JobActivationForm

java.lang.Object
io.jenkins.plugins.batchcontrol.action.JobActivationForm
All Implemented Interfaces:
Action, ModelObject

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public class JobActivationForm extends Object implements Action
The activation request form at <item>/batch-control-activation/ (SPEC item 6a, D-39, D-64) for a job (JobRequestActionFactory) or a computed folder, which carries the activation of its children (D-46c, ComputedFolderActivationActionFactory). An action of its own, without a sidebar entry, so its breadcrumbs read <item> > Activation. Without BatchControl/Request getUrlName() is null: the URL space answers 404, so this form is never shown to a user who could not submit it.

The form offers the one action that can change anything: ACTIVATE for a job that is not activated, HOLD for one that is. doSubmit(org.kohsuke.stapler.StaplerRequest2, org.kohsuke.stapler.StaplerResponse2) passes the posted value to ActivationService.create(hudson.model.Job<?, ?>, io.jenkins.plugins.batchcontrol.model.ActivationRequest.Action, java.lang.String, java.util.List<java.lang.String>), which is the only place a request is validated and stored; this class holds no state logic.

  • Method Summary

    Modifier and Type
    Method
    Description
    S-13-08: the request kind as the screens word it.
    void
    doSubmit(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp)
    POST submit with action (ACTIVATE|HOLD), reason and the repeated approvers field; redirects to the request at /batch-control/activations/<id>/.
    format(Instant instant)
    Jelly helper: human-readable timestamp.
    Approver candidates: global approver list ∩ job-level restriction (if configured).
    A computed child carries no activation of its own: the item returned here does (D-46c).
     
    The refusal of the last submission on this request, or an empty one (DEF-09).
    No sidebar entry: the job and folder pages link the form from their activation notice.
     
    The action a new request would ask for: HOLD when activated, else ACTIVATE.
    Job<?,?>
    The job, under the name core's l:job-subpage reads (it.object), so the form renders as a sub-page of the job on the new job page (e2e-14 DEF-08); null for a computed folder, which the view keeps on the classic layout.
    The PENDING requests of this job the viewer may see (P-09), oldest first.
     
    null without BatchControl/Request: the form exposes the approver list, so its URL space is absent (404) rather than refused, the same rule as before D-64 (on a job BatchControl/Request; on a computed folder the service's predicate, Request and Item/Read).
    Permissions for the form's l:layout.
    boolean
    Whether the job may run on timer and upstream triggers as far as activation is concerned.
    boolean
    S-14-02: whether the viewer holds Item/Read on the carrier, so its name may be shown; otherwise the view renders a neutral line.
    boolean
    Whether the target is a computed folder rather than a job (the view words it accordingly).
    boolean
    Whether an approved hold took the job out of service (as opposed to never activated).
    boolean
    Whether run control is on, i.e.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface hudson.model.Action

    getDescription, getEvent, getGroup, getSemantic, isVisibleInContextMenu
  • Method Details

    • getItem

      public Item getItem()
    • getObject

      @CheckForNull public Job<?,?> getObject()
      The job, under the name core's l:job-subpage reads (it.object), so the form renders as a sub-page of the job on the new job page (e2e-14 DEF-08); null for a computed folder, which the view keeps on the classic layout.
    • isFolder

      public boolean isFolder()
      Whether the target is a computed folder rather than a job (the view words it accordingly).
    • getDisplayName

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

      @CheckForNull public String getIconFileName()
      No sidebar entry: the job and folder pages link the form from their activation notice.
      Specified by:
      getIconFileName in interface Action
    • getUrlName

      @CheckForNull public String getUrlName()
      null without BatchControl/Request: the form exposes the approver list, so its URL space is absent (404) rather than refused, the same rule as before D-64 (on a job BatchControl/Request; on a computed folder the service's predicate, Request and Item/Read). doSubmit(org.kohsuke.stapler.StaplerRequest2, org.kohsuke.stapler.StaplerResponse2) re-checks the permissions. Always null on a job's sub-item (a matrix configuration, a Maven module), which has no activation of its own (D-82): its notice links the parent job instead.
      Specified by:
      getUrlName in interface Action
    • getViewPermissions

      public Permission[] getViewPermissions()
      Permissions for the form's l:layout.
    • isActivated

      public boolean isActivated()
      Whether the job may run on timer and upstream triggers as far as activation is concerned.
    • isHeld

      public boolean isHeld()
      Whether an approved hold took the job out of service (as opposed to never activated).
    • getCarrier

      @CheckForNull public Item getCarrier()
      A computed child carries no activation of its own: the item returned here does (D-46c). null for an item that carries its own.
    • isCarrierReadable

      public boolean isCarrierReadable()
      S-14-02: whether the viewer holds Item/Read on the carrier, so its name may be shown; otherwise the view renders a neutral line.
    • isRunControlled

      public boolean isRunControlled()
      Whether run control is on, i.e. the gate applies (D-46a: whatever approvalRequired says).
    • getState

      @CheckForNull public ActivationState getState()
    • getNextAction

      public String getNextAction()
      The action a new request would ask for: HOLD when activated, else ACTIVATE.
    • getPendingRequests

      public List<ActivationRequest> getPendingRequests()
      The PENDING requests of this job the viewer may see (P-09), oldest first.
    • getApproverOptions

      public List<String> getApproverOptions()
      Approver candidates: global approver list ∩ job-level restriction (if configured).
    • actionLabel

      public String actionLabel(ActivationRequest.Action action)
      S-13-08: the request kind as the screens word it.
    • format

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

      public void doSubmit(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException
      POST submit with action (ACTIVATE|HOLD), reason and the repeated approvers field; redirects to the request at /batch-control/activations/<id>/. A refused submission re-renders the form (HTTP 400) with the message next to its field and the input kept (e2e-03 DEF-09).
      Throws:
      IOException
      jakarta.servlet.ServletException
    • getFormErrors

      public FormErrors getFormErrors()
      The refusal of the last submission on this request, or an empty one (DEF-09).