Same problem discovered in our multi-branch Jenkinsfile pipeline (not in Declarative Pipeline context but same problem I guess...). The inversePrecedence:true doesn't seem to work reliably. Specifically, I've tried to protect our long-running integration tests with a LIFO queue using the following pipeline script:
[...] stage('Integration testing') {
milestone(label: 'IntegrationTests-AttemptingToStart')
String lockResource = "integrationTests-${env.BRANCH_NAME}"
lock(resource: lockResource, inversePrecedence: true) {
try {
integrationTestsStage() } finally {
echo "Done with all integration tests."
milestone(label:'IntegrationTests-Done') }
}
}
It did not work, the builds entered the integrationTests stage in strange orders and sometimes even two builds at the same time.
Update a few hours later:
After some more investigation I think the problem is that one cannot have nested lock()s in a pipeline. In our case above, the parallel steps run within integrationTestsStage each hold an additional resource (DB) lock. But whenever one of the inner locks is released, all other locks held by the same build also get released.
I believe this is not only when using inversePrecedence, so may be a different bug?
For the reference: Our environment is Jenkins 2.37 with latest versions of all pipeline-related plugins
Same problem discovered in our multi-branch Jenkinsfile pipeline (not in Declarative Pipeline context but same problem I guess...). The inversePrecedence:true doesn't seem to work reliably. Specifically, I've tried to protect our long-running integration tests with a LIFO queue using the following pipeline script:
It did not work, the builds entered the integrationTests stage in strange orders and sometimes even two builds at the same time.
Update a few hours later:
After some more investigation I think the problem is that one cannot have nested lock()s in a pipeline. In our case above, the parallel steps run within integrationTestsStage each hold an additional resource (DB) lock. But whenever one of the inner locks is released, all other locks held by the same build also get released.
I believe this is not only when using inversePrecedence, so may be a different bug?
For the reference: Our environment is Jenkins 2.37 with latest versions of all pipeline-related plugins