Class LockableResource
java.lang.Object
hudson.model.AbstractDescribableImpl<LockableResource>
org.jenkins.plugins.lockableresources.LockableResource
- All Implemented Interfaces:
Describable<LockableResource>,Serializable
@ExportedBean(defaultVisibility=999)
public class LockableResource
extends AbstractDescribableImpl<LockableResource>
implements Serializable
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLockableResource(String name) Deprecated.Use single-argument constructor instead (since 1.8) -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyUnconfigurableProperties(LockableResource sourceResource) Copy unconfigurable properties from another instance.booleanRun<?,?> getBuild()Deprecated.Get labels of this resourceResolve the lock cause for this resource.Resolve the lock detailed cause for this resource.getName()getNote()List<org.jenkinsci.plugins.workflow.steps.StepContext>Deprecated.Replaced with LockableResourcesManager.queuedContexts (since 1.11)longgetTask()static StringinthashCode()booleanChecks if the resource has label *labelToFind*booleanbooleanisFree()Return true when resource is free.booleanisLocked()booleanbooleanisQueued()booleanisQueued(long taskId) booleanisQueuedByTask(long taskId) booleanbooleanFunction check if the resources is reserved by currently logged userbooleanisStolen()booleanisValidLabel(String candidate) Check if the given *candidate* label is valid or not.booleanisValidLabel(String candidate, Map<String, Object> params) Deprecated.Use isValidLabel(String candidate)protected Objectvoidrecycle()Tell LRM to recycle this resource, including notifications for whoever may be waiting in the queue so they can proceed immediately.voidvoidreset()voidReset unconfigurable properties.booleanscriptMatches(org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript script, Map<String, Object> params) Checks if the script matches the requirement.voidvoidsetDescription(String description) voidsetEphemeral(boolean ephemeral) voidDeprecated.no equivalent at the time.voidsetNodeResource(boolean b) voidvoidsetProperties(List<LockableResourceProperty> properties) voidsetQueued(long queueItemId) voidvoidsetReservedBy(String userName) voidsetReservedTimestamp(Date reservedTimestamp) voidtoString()voidunqueue()voidMethods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
Field Details
-
NOT_QUEUED
public static final int NOT_QUEUED- See Also:
-
GROOVY_LABEL_MARKER
- See Also:
-
-
Constructor Details
-
Method Details
-
readResolve
-
getQueuedContexts
Deprecated.Replaced with LockableResourcesManager.queuedContexts (since 1.11) -
isNodeResource
public boolean isNodeResource() -
setNodeResource
public void setNodeResource(boolean b) -
getName
-
getDescription
-
setDescription
-
getNote
-
setNote
-
setEphemeral
@DataBoundSetter public void setEphemeral(boolean ephemeral) -
isEphemeral
@Exported public boolean isEphemeral() -
getLabels
Deprecated.Use getLabelsAsList instead todo This function is marked as deprecated but it is still used in tests and jelly (config) files. -
setLabels
Deprecated.no equivalent at the time. todo It shall be created new one function selLabelsAsList() and use that one. But it must be checked and changed all config.jelly files and this might takes more time as expected. That the reason why a deprecated function/property is still data-bound-setter -
getLabelsAsList
Get labels of this resource- Returns:
- List of assigned labels.
-
hasLabel
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean hasLabel(@CheckForNull String labelToFind) Checks if the resource has label *labelToFind*- Parameters:
labelToFind- Label to find.- Returns:
trueif this resource contains the label.
-
isValidLabel
Deprecated.Use isValidLabel(String candidate) -
isValidLabel
Check if the given *candidate* label is valid or not. candidate may be one label or Label expression (see also https://www.jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#node-allocate-node). Valid means that the resource contains the label or the Label-expression matched. -
getProperties
-
setProperties
-
scriptMatches
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean scriptMatches(@NonNull org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript script, @CheckForNull Map<String, Object> params) throws ExecutionExceptionChecks if the script matches the requirement.- Parameters:
script- Script to be executedparams- Extra script parameters- Returns:
trueif the script returns true (resource matches).- Throws:
ExecutionException- Script execution failed (e.g. due to the missing permissions). Carries info in the cause
-
getReservedTimestamp
-
setReservedTimestamp
-
getReservedBy
-
isFree
@Exported public boolean isFree()Return true when resource is free. False otherwise -
isReserved
@Exported public boolean isReserved() -
getUserName
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @CheckForNull public static String getUserName() -
isReservedByCurrentUser
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isReservedByCurrentUser()Function check if the resources is reserved by currently logged user- Returns:
- true when reserved by current user, false otherwise.
-
getReservedByEmail
-
isQueued
public boolean isQueued() -
isQueued
public boolean isQueued(long taskId) -
isQueuedByTask
public boolean isQueuedByTask(long taskId) -
unqueue
public void unqueue() -
isLocked
@Exported public boolean isLocked() -
getLockCause
Resolve the lock cause for this resource. It can be reserved or locked.- Returns:
- the lock cause or null if not locked
-
getLockCauseDetail
@CheckForNull @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public String getLockCauseDetail()Resolve the lock detailed cause for this resource. Note: this function is used in lock() step and not in the UI. Therefore moving text into localization files does not make really sense.- Returns:
- the lock cause or null if not locked
-
getBuild
-
getBuildName
-
setBuild
-
getTask
-
getQueueItemId
public long getQueueItemId() -
getQueueItemProject
-
setQueued
public void setQueued(long queueItemId) -
setQueued
-
setReservedBy
-
setStolen
public void setStolen() -
isStolen
@Exported public boolean isStolen() -
reserve
-
unReserve
public void unReserve() -
reset
public void reset() -
copyUnconfigurableProperties
Copy unconfigurable properties from another instance. Normally, called after "lockable resource" configuration change.- Parameters:
sourceResource- resource with properties to copy from
-
resetUnconfigurableProperties
public void resetUnconfigurableProperties()Reset unconfigurable properties. Normally, called after "lockable resource" configuration change, to make sure that these fields are ignored if defined in CasC configuration file. -
recycle
public void recycle()Tell LRM to recycle this resource, including notifications for whoever may be waiting in the queue so they can proceed immediately. WARNING: Do not use this from inside the lock step closure which originally locked this resource, to avoid nasty surprises! Just stick with unReserve() and close the closure, if needed. -
toString
-
hashCode
public int hashCode() -
equals
-