Class LockStepExecution

java.lang.Object
org.jenkinsci.plugins.workflow.steps.StepExecution
org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl
org.jenkins.plugins.lockableresources.LockStepExecution
All Implemented Interfaces:
Serializable, RemoteLockSession.Host

public class LockStepExecution extends org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl implements RemoteLockSession.Host
See Also:
  • Constructor Details

    • LockStepExecution

      public LockStepExecution(LockStep step, org.jenkinsci.plugins.workflow.steps.StepContext context)
  • Method Details

    • start

      public boolean start() throws Exception
      Specified by:
      start in class org.jenkinsci.plugins.workflow.steps.StepExecution
      Throws:
      Exception
    • context

      public org.jenkinsci.plugins.workflow.steps.StepContext context()
      Description copied from interface: RemoteLockSession.Host
      The workflow step context (for Run/FlowNode/TaskListener, onSuccess/onFailure).
      Specified by:
      context in interface RemoteLockSession.Host
    • step

      public LockStep step()
      Description copied from interface: RemoteLockSession.Host
      The originating lock() step.
      Specified by:
      step in interface RemoteLockSession.Host
    • runBody

      public void runBody(String displayTarget, @CheckForNull Map<String,String> lockEnvVars, String lockId)
      Description copied from interface: RemoteLockSession.Host
      Runs the lock body; on completion the framework releases the remote lock via RemoteLockSession.onBodyFinished(Host).
      Specified by:
      runBody in interface RemoteLockSession.Host
    • proceed

      public static void proceed(LinkedHashMap<String,List<LockableResourceProperty>> lockedResources, org.jenkinsci.plugins.workflow.steps.StepContext context, String resourceDescription, String variable)
    • proceed

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void proceed(LinkedHashMap<String,List<LockableResourceProperty>> lockedResources, org.jenkinsci.plugins.workflow.steps.StepContext context, String resourceDescription, String variable, @CheckForNull String shareHolderEntry, @CheckForNull String shareId)
    • proceed

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void proceed(LinkedHashMap<String,List<LockableResourceProperty>> lockedResources, org.jenkinsci.plugins.workflow.steps.StepContext context, String resourceDescription, String variable, @CheckForNull String shareHolderEntry, @CheckForNull String shareId, long onReleaseDelay, long onCancelDelay)
      Starts the lock body. shareHolderEntry is the holder entry the block was recorded under (see shareHolderEntry(hudson.model.Run<?, ?>, org.jenkinsci.plugins.workflow.steps.StepContext)); the block end then removes only that entry. When null the block end frees the resources of the build as before. shareId is the share id of the block, recorded in the build's lock log. Once the resources are freed, that is when the last holder block has left, they stay locked for onReleaseDelay more seconds, or for onCancelDelay seconds when the build was aborted.
    • buildLockEnvVars

      @CheckForNull public static Map<String,String> buildLockEnvVars(@CheckForNull String variable, @NonNull LinkedHashMap<String,List<LockableResourceProperty>> lockedResources)
      Builds the lockEnvVars map injected for the duration of a lock() block, following local semantics exactly: variable="X" with locked resources r1, r2 yields X="r1,r2", X0="r1", X0_<prop>=<value>, X1="r2", ... Property env vars are included. The first (index 0) resource's properties are additionally exposed without the numeric index (X_<prop>=<value>) for the common single-resource lock (JENKINS-75943). Returns null when variable is null/empty.

      Shared by the local flow (proceed(java.util.LinkedHashMap<java.lang.String, java.util.List<org.jenkins.plugins.lockableresources.LockableResourceProperty>>, org.jenkinsci.plugins.workflow.steps.StepContext, java.lang.String, java.lang.String)) and the remote bridge so the two never drift. All inputs (resource names and property name/value strings) are serializable, so the remote server can generate the same map and bridge it to the client.

    • buildLockEnvVars

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @CheckForNull public static Map<String,String> buildLockEnvVars(@CheckForNull String variable, @NonNull LinkedHashMap<String,List<LockableResourceProperty>> lockedResources, @NonNull Map<String,String> resourceLabels)
      Builds lock environment variables with indexed labels and a first-resource label alias.
    • stop

      public void stop(@NonNull Throwable cause)
      Overrides:
      stop in class org.jenkinsci.plugins.workflow.steps.StepExecution
    • onResume

      public void onResume()
      Overrides:
      onResume in class org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl