lockable-resources-plugin
lockable-resources-plugin copied to clipboard
Unclear about declarative pipeline
I am trying to rewrite my pipeline script for maintainablity but am unclear how to lock the resource for the entire script, is it possible to do something like:
pipeline {
agent any
resource: ('lockable resource')
stages {
stage('Build') {
steps {
sh 'make'
}
}
stage('Test'){
steps {
sh 'make check'
junit 'reports/**/*.xml'
}
}
stage('Deploy') {
steps {
sh 'make publish'
}
}
}
}
I have a similar problem. This would be a great feature. Also, take a look on JENKINS-43336. This could be resolved with the same solution. PS. You can vote for issue ;)
You can lock the entire job in the options block of the pipeline:
pipeline {
options {
lock resource: 'lockable resource'
}
agent any
stages {
stage('Build') {
steps {
sh 'make'
}
}
stage('Test'){
steps {
sh 'make check'
junit 'reports/**/*.xml'
}
}
stage('Deploy') {
steps {
sh 'make publish'
}
}
}
}