Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock resources whose names are provided by build parameters. #685

Open
GarfieldJiang opened this issue Jul 22, 2024 · 1 comment
Open

Lock resources whose names are provided by build parameters. #685

GarfieldJiang opened this issue Jul 22, 2024 · 1 comment

Comments

@GarfieldJiang
Copy link

GarfieldJiang commented Jul 22, 2024

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

@PayBas
Copy link
Contributor

PayBas commented Jul 29, 2024

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"
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants