Class BatchControlStrategyMonitor

java.lang.Object
hudson.model.AbstractModelObject
hudson.model.AdministrativeMonitor
io.jenkins.plugins.batchcontrol.ops.BatchControlStrategyMonitor
All Implemented Interfaces:
ExtensionPoint, ModelObject, SearchableModelObject, SearchItem, org.kohsuke.stapler.StaplerProxy

@Extension @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public class BatchControlStrategyMonitor extends AdministrativeMonitor
"Change control is on, but the installed authorization strategy is not a Batch Control strategy" (D-35a, ARCHITECTURE section 4). Grants confer nothing then. This covers an instance that never migrated and a plain strategy installed on the global security page (or by JCasC). role-strategy's own pages keep the installed Batch Control class from version 918 on (D-35f), so they are no longer a cause.

It also warns while change control is on and no build authenticator is configured, so builds run as SYSTEM (D-35d (2), isBuildAuthenticatorMissing()).

doMigrate() (the "Install the Batch Control variant" button, POST and Overall/Administer only) is the only path that converts a plain strategy; nothing converts one on load (D-35e). It copies an installed plain matrix-auth matrix (project-based, or global: then per-item properties become effective, isPerItemWidening()) or role-strategy configuration into the matching Batch Control subclass, keeping every entry; doRevert() is the reverse, the uninstall path. Neither touches per-item properties, which live on the items. Neither switches to ACL.SYSTEM2: an administrator runs them and Jenkins.save() needs no further permission.

Both actions work whether or not the monitor is activated: its URL (/manage/administrativeMonitor/batch-control-strategy/) only requires Overall/Administer, and the revert button lives on the Batch Control global configuration page, where a Batch Control strategy is installed and the monitor is therefore quiet. After success both redirect back to the referring page of this Jenkins, or to the global security page.

matrix-auth and role-strategy are optional: this class refers to neither, see StrategyMigration.

  • Field Details

  • Constructor Details

    • BatchControlStrategyMonitor

      public BatchControlStrategyMonitor()
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface ModelObject
      Overrides:
      getDisplayName in class AdministrativeMonitor
    • isActivated

      public boolean isActivated()
      Shows while change control is on and either the installed strategy is not a Batch Control strategy (isStrategyUnsupported()) or builds run as SYSTEM (isBuildAuthenticatorMissing()).
      Specified by:
      isActivated in class AdministrativeMonitor
    • isBuildsMayRunAsSystem

      public boolean isBuildsMayRunAsSystem()
      Condition 3 (D-50, D-50a): with change control on, a build of a job without its own build authorization and without a user cause would run as SYSTEM under the configured build authenticators (for example Authorize Project per-project, or a strategy that follows the triggering user). Instance-wide and cached (SystemBuildCheck), so rendering a page never probes on every call.
    • isStrategyUnsupported

      public boolean isStrategyUnsupported()
      Condition 1 (D-35a): change control is on, but the installed strategy is not a Batch Control strategy, so active grants confer nothing (for the view).
    • isBuildAuthenticatorMissing

      public boolean isBuildAuthenticatorMissing()
      Condition 2 (D-35d (2), S-02): change control is on and no QueueItemAuthenticator is configured, so builds run as SYSTEM. A build running as SYSTEM (a Pipeline properties([authorizationMatrix(...)]) step, a Job DSL seed job) can then write an authorization property after a Configure grant holder edited the script, and the D-35b guard does not apply to SYSTEM saves. Configuring a build authenticator (Authorize Project) makes those saves the user's, so the guard applies. Only a warning: SYSTEM saves are not blocked.
    • isMigratable

      public boolean isMigratable()
      Whether the installed strategy can be copied into a Batch Control subclass (for the view).
    • isPerItemWidening

      public boolean isPerItemWidening()
      Whether the migration would make per-item authorization properties effective (D-35d (3), S-04): the installed strategy is matrix-auth's global matrix, which ignores job, folder and agent properties, while the Batch Control matrix is project-based (for the view's warning).
    • isRevertable

      public boolean isRevertable()
      Whether a Batch Control strategy is installed, so that doRevert() applies.
    • getInstalledStrategyName

      @CheckForNull public String getInstalledStrategyName()
      The display name of the installed strategy (for the view).
    • doMigrate

      public org.kohsuke.stapler.HttpResponse doMigrate() throws IOException
      Installs the Batch Control subclass of the current plain matrix-auth (project or global) or role-strategy strategy with every entry kept, and saves. Other strategies are refused with a plain message page (HTTP 400).
      Throws:
      IOException
    • doRevert

      public org.kohsuke.stapler.HttpResponse doRevert() throws IOException
      Installs the plain parent strategy of the current Batch Control strategy with every entry kept, and saves (the uninstall path). Grants stop conferring immediately. Refused with a plain message page (HTTP 400) when no Batch Control strategy is installed.
      Throws:
      IOException
    • getItemsChangedUnderGrant

      public List<String> getItemsChangedUnderGrant()
      D-58a: the items in the "changed under a grant" state (saved or created under a grant and not reviewed since by an administrator or a native Configure holder through the web), sorted, at most 50. They stay guarded until reviewed. Administrator-only page.
    • doMarkReviewed

      public org.kohsuke.stapler.HttpResponse doMarkReviewed(@QueryParameter String item)
      D-58b (3): "Mark as reviewed" for one listed item. Administrators only; the item and everything below it leave the "changed under a grant" state and a GUARD_REVIEWED record is written, then the confirmation page (batch-control/reviewed) is shown. Answers 404 for an item that does not exist.