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 Summary
ConstructorsConstructorDescriptionLockStepExecution(LockStep step, org.jenkinsci.plugins.workflow.steps.StepContext context) -
Method Summary
Modifier and TypeMethodDescriptionbuildLockEnvVars(String variable, LinkedHashMap<String, List<LockableResourceProperty>> lockedResources) Builds thelockEnvVarsmap injected for the duration of alock()block, following local semantics exactly:variable="X"with locked resourcesr1, r2yieldsX="r1,r2",X0="r1",X0_<prop>=<value>,X1="r2", ...buildLockEnvVars(String variable, LinkedHashMap<String, List<LockableResourceProperty>> lockedResources, Map<String, String> resourceLabels) Builds lock environment variables with indexed labels and a first-resource label alias.org.jenkinsci.plugins.workflow.steps.StepContextcontext()The workflow step context (forRun/FlowNode/TaskListener, onSuccess/onFailure).voidonResume()static voidproceed(LinkedHashMap<String, List<LockableResourceProperty>> lockedResources, org.jenkinsci.plugins.workflow.steps.StepContext context, String resourceDescription, String variable) static voidproceed(LinkedHashMap<String, List<LockableResourceProperty>> lockedResources, org.jenkinsci.plugins.workflow.steps.StepContext context, String resourceDescription, String variable, String shareHolderEntry, String shareId) static voidproceed(LinkedHashMap<String, List<LockableResourceProperty>> lockedResources, org.jenkinsci.plugins.workflow.steps.StepContext context, String resourceDescription, String variable, String shareHolderEntry, String shareId, long onReleaseDelay, long onCancelDelay) Starts the lock body.voidRuns the lock body; on completion the framework releases the remote lock viaRemoteLockSession.onBodyFinished(Host).booleanstart()step()The originatinglock()step.voidMethods inherited from class org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl
injectMethods inherited from class org.jenkinsci.plugins.workflow.steps.StepExecution
acceptAll, acceptAll, applyAll, applyAll, blocksRestart, getContext, getStatus, getStatusBounded
-
Constructor Details
-
LockStepExecution
-
-
Method Details
-
start
- Specified by:
startin classorg.jenkinsci.plugins.workflow.steps.StepExecution- Throws:
Exception
-
context
public org.jenkinsci.plugins.workflow.steps.StepContext context()Description copied from interface:RemoteLockSession.HostThe workflow step context (forRun/FlowNode/TaskListener, onSuccess/onFailure).- Specified by:
contextin interfaceRemoteLockSession.Host
-
step
Description copied from interface:RemoteLockSession.HostThe originatinglock()step.- Specified by:
stepin interfaceRemoteLockSession.Host
-
runBody
public void runBody(String displayTarget, @CheckForNull Map<String, String> lockEnvVars, String lockId) Description copied from interface:RemoteLockSession.HostRuns the lock body; on completion the framework releases the remote lock viaRemoteLockSession.onBodyFinished(Host).- Specified by:
runBodyin interfaceRemoteLockSession.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.shareHolderEntryis the holder entry the block was recorded under (seeshareHolderEntry(hudson.model.Run<?, ?>, org.jenkinsci.plugins.workflow.steps.StepContext)); the block end then removes only that entry. Whennullthe block end frees the resources of the build as before.shareIdis 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 foronReleaseDelaymore seconds, or foronCancelDelayseconds when the build was aborted. -
buildLockEnvVars
@CheckForNull public static Map<String,String> buildLockEnvVars(@CheckForNull String variable, @NonNull LinkedHashMap<String, List<LockableResourceProperty>> lockedResources) Builds thelockEnvVarsmap injected for the duration of alock()block, following local semantics exactly:variable="X"with locked resourcesr1, r2yieldsX="r1,r2",X0="r1",X0_<prop>=<value>,X1="r2", ... Property env vars are included. The first (index0) resource's properties are additionally exposed without the numeric index (X_<prop>=<value>) for the common single-resource lock (JENKINS-75943). Returnsnullwhenvariableis 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
- Overrides:
stopin classorg.jenkinsci.plugins.workflow.steps.StepExecution
-
onResume
public void onResume()- Overrides:
onResumein classorg.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl
-