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:
  • Field Details

  • Constructor Details

    • LockableResource

      @Deprecated public LockableResource(String name, String description, String labels, String reservedBy, String note)
      Deprecated.
      Use single-argument constructor instead (since 1.8)
    • LockableResource

      @DataBoundConstructor public LockableResource(@CheckForNull String name)
  • Method Details

    • readResolve

      protected Object readResolve()
    • getQueuedContexts

      @Deprecated public List<org.jenkinsci.plugins.workflow.steps.StepContext> getQueuedContexts()
      Deprecated.
      Replaced with LockableResourcesManager.queuedContexts (since 1.11)
    • isNodeResource

      public boolean isNodeResource()
    • setNodeResource

      public void setNodeResource(boolean b)
    • getName

      @Exported public String getName()
    • getDescription

      @Exported public String getDescription()
    • setDescription

      @DataBoundSetter public void setDescription(@Nullable String description)
    • getNote

      @Exported public String getNote()
    • setNote

      @DataBoundSetter public void setNote(@Nullable String note)
    • setEphemeral

      @DataBoundSetter public void setEphemeral(boolean ephemeral)
    • isEphemeral

      @Exported public boolean isEphemeral()
    • getLabels

      @Deprecated @Exported public String getLabels()
      Deprecated.
      Use getLabelsAsList instead todo This function is marked as deprecated but it is still used in tests and jelly (config) files.
    • setLabels

      @DataBoundSetter public void setLabels(@Nullable String labels)
      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

      @Exported public List<String> 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 public boolean isValidLabel(String candidate, Map<String,Object> params)
      Deprecated.
      Use isValidLabel(String candidate)
    • isValidLabel

      public boolean isValidLabel(@Nullable String candidate)
      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

      @Exported public List<LockableResourceProperty> getProperties()
    • setProperties

      @DataBoundSetter public void setProperties(@Nullable List<LockableResourceProperty> properties)
    • 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 ExecutionException
      Checks if the script matches the requirement.
      Parameters:
      script - Script to be executed
      params - 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

      @Exported public Date getReservedTimestamp()
    • setReservedTimestamp

      @DataBoundSetter public void setReservedTimestamp(@Nullable Date reservedTimestamp)
    • getReservedBy

      @Exported public String 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

      @Exported public String 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

      @CheckForNull @Exported public String 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

      @Exported public String getBuildName()
    • setBuild

      public void setBuild(@Nullable Run<?,?> lockedBy)
    • getTask

      public Queue.Task getTask()
    • getQueueItemId

      public long getQueueItemId()
    • getQueueItemProject

      public String getQueueItemProject()
    • setQueued

      public void setQueued(long queueItemId)
    • setQueued

      public void setQueued(long queueItemId, String queueProjectName)
    • setReservedBy

      @DataBoundSetter public void setReservedBy(String userName)
    • setStolen

      public void setStolen()
    • isStolen

      @Exported public boolean isStolen()
    • reserve

      public void reserve(String userName)
    • unReserve

      public void unReserve()
    • reset

      public void reset()
    • copyUnconfigurableProperties

      public void copyUnconfigurableProperties(LockableResource sourceResource)
      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

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object