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
-
Field Summary
-
Constructor Summary
ConstructorDescriptionLockableResource
(String name) Deprecated.Use single-argument constructor instead (since 1.8) -
Method Summary
Modifier and TypeMethodDescriptionvoid
copyUnconfigurableProperties
(LockableResource sourceResource) Copy unconfigurable properties from another instance.boolean
Run<?,
?> 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)long
getTask()
static String
int
hashCode()
boolean
Checks if the resource has label *labelToFind*boolean
boolean
isFree()
Return true when resource is free.boolean
isLocked()
boolean
boolean
isQueued()
boolean
isQueued
(long taskId) boolean
isQueuedByTask
(long taskId) boolean
boolean
Function check if the resources is reserved by currently logged userboolean
isStolen()
boolean
isValidLabel
(String candidate) Check if the given *candidate* label is valid or not.boolean
isValidLabel
(String candidate, Map<String, Object> params) Deprecated.Use isValidLabel(String candidate)protected Object
void
recycle()
Tell LRM to recycle this resource, including notifications for whoever may be waiting in the queue so they can proceed immediately.void
void
reset()
boolean
scriptMatches
(org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript script, Map<String, Object> params) Checks if the script matches the requirement.void
void
setDescription
(String description) void
setEphemeral
(boolean ephemeral) void
Deprecated.no equivalent at the time.void
setNodeResource
(boolean b) void
void
setProperties
(List<LockableResourceProperty> properties) void
setQueued
(long queueItemId) void
void
setReservedBy
(String userName) void
setReservedTimestamp
(Date reservedTimestamp) void
toString()
void
unqueue()
void
Methods 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:
true
if 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:
true
if 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
@WithBridgeMethods(value=hudson.model.AbstractBuild.class, adapterMethod="getAbstractBuild") public Run<?,?> 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
-
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
-