The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.

For a list of other such plugins, see the Pipeline Steps Reference page.

Lockable Resources plugin

lock: Lock shared resource

  • resource

    The resource name to lock as defined in Global settings. If the resource does not exist in Global Settings it will be automatically created on build execution. Either a resource or a label need to be specified.

    • Type: String
  • extra (optional)
      Array / List of Nested Object
    • resource

      The resource name to lock as defined in Global settings. If the resource does not exist in Global Settings it will be automatically created on build execution. Either a resource or a label need to be specified.

      • Type: String
    • label (optional)

      The label of the resources to be locked as defined in Global settings. Either a resource or a label need to be specified.

      • Type: String
    • quantity (optional)

      The quantity of resources with the specified label to be locked as defined in Global settings. Either a resource or a label need to be specified. Empty value or 0 means lock all matching resources.

      • Type: int
  • inversePrecedence (optional)

    By default waiting builds get the lock in the same order they requested to acquire it.

    By checking this option the newest build in the waiting queue will get the lock first.

    • Type: boolean
  • label (optional)

    The label of the resources to be locked as defined in Global settings. Either a resource or a label need to be specified.

    • Type: String
  • quantity (optional)

    The quantity of resources with the specified label to be locked as defined in Global settings. Either a resource or a label need to be specified. Empty value or 0 means lock all matching resources.

    • Type: int
  • skipIfLocked (optional)

    By default waiting builds get the lock.

    By checking this option the body will not be executed if there is a queue. It will only take the lock if it can be taken immediately.

    • Type: boolean
  • variable (optional)

    Name of an environment variable that will receive the comma separated list of the names of the locked resources while the block executes.

    e.g.:

    lock(label: 'label', variable: 'var') {
        echo "Resource locked: ${env.var}"
    }
    		

    • Type: String

Was this page helpful?

Please submit your feedback about this page through this quick form.

Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?

    


See existing feedback here.