Open MacMan314 opened 2 years ago
An update to this issue, a workaround is to put the lock() step inside a script {} block. This will work:
stage("Functional lock by label") {
steps {
script {
lock(label: 'shared_label', variable: 'LABEL_LOCKED', quantity: 1) {
echo "Lock acquired: ${LABEL_LOCKED}"
}
}
}
}
This will not:
stage("Bugged lock") {
steps {
lock(label: 'shared_label', variable: 'LABEL_LOCKED', quantity: 1) {
echo "Lock acquired: ${LABEL_LOCKED}"
}
}
}
Thanks, solutions (PRs, at least for docs - better for code) are also welcome ;)
One more known workaround is to specify a resource: null
parameter to lock()
I'm trying to fix that thing. I already managed to build a test case that reproduces the issue. Now, if I am able to also fix it, I'll submit my first PR :D Edit: https://github.com/mark-reiche/lockable-resources-plugin/tree/pr-issue-278-lock-via-label
@mark-reiche can you open the PR please. I am interested for your solution. We have currently documented the workaround proposed by @jimklimov .
When there are no solutions I will propose to close this issue, because a applicable workaround is documented.
Thx for contributing
See also #441
Version report
Jenkins and plugins versions report:
Reproduction steps
Results
Expected result:
One resource should become locked .
Actual result:
[Pipeline] End of Pipeline org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed: test_script.groovy: 27: Missing required parameter: "resource" @ line 27, column 15. lock(label: 'shared_label', variable: 'LABEL_LOCKED') { ^