Reputation: 1120
We have a use case where we have two different Jenkins pipelines, A and B, where A can trigger B and B can trigger A, but we want to be able to constrain A and B so that A can't run if B is still running and vice versa.
I know how one can create a single pipeline and prevent it from running multiple copies of itself, but is there a way we can have a pipeline check the status of another job and block until that other job has finished?
Upvotes: 1
Views: 46
Reputation: 9075
It sounds like you need the lockable resource plugin
from its page:
echo 'Starting'
lock('my-resource-name') {
echo 'Do something here that requires unique access to the resource'
// any other build will wait until the one locking the resource leaves this block
}
echo 'Finish'
Upvotes: 1