Jenkins declarative pipeline lock current JenkinsAgent (env.NODE_NAME)

Viewed 207

Is it possible to lock the current Agent (env.NODE_NAME) for all of stages in the Pipeline

pipeline {
agent any
options{
    lock (
    resource: '${env.NODE_NAME}',
    quantity: 1,
    skipIfLocked: true
    )
}

stages{
    stage('stage') {
        steps {
            echo "Something"
        }
    }
}
}

Log:

Trying to acquire lock on [${env.NODE_NAME}]
Resource [${env.NODE_NAME}] did not exist. Created.
Lock acquired on [${env.NODE_NAME}]
0 Answers
Related