lockable-resources-plugin icon indicating copy to clipboard operation
lockable-resources-plugin copied to clipboard

Lock resources whose names are provided by build parameters.

Open GarfieldJiang opened this issue 1 year ago • 1 comments

What feature do you want to see added?

For example, I have 3 resources A, B, C. For each of the resources, only one job can lock it. However, I hope to choose the resource to lock in the build parameters of the job. Is this easy to implement?

Things should be like the following, or something similar?

steps {
    lock ('${params.LOCK_RESOURCE}') {
        echo 'Hello World'
        sleep 60
    }
}

Upstream changes

No response

Are you interested in contributing this feature?

No response

GarfieldJiang avatar Jul 22 '24 12:07 GarfieldJiang

I've been using this for years.

pipeline {
  agent none
  parameters {
    string(name: 'device', trim: true)
  }
  options {
    lock(resource: params.device)
  }
  stages {
    stage('Use it') {
      agent any
      steps {
        echo "hi"
      }
    }
  }
}

PayBas avatar Jul 29 '24 22:07 PayBas