Our project uses Jenkins pipeline for the automation tests and packaging. The pipeline is defined in a Jenkinsfile
script having multiple stages. Multiple jobs (triggered by the push events from different dev branches) might be running in parallel.
Now that we need to test a function against an external system which has limited resources.
Let's say, that system has 10 resource "slots" for tests: #1, #2, ..., #10. When each pipeline job wants to test that function, it needs to "reserve" a slot number (just an integer will suffice) and then the test program talks to the external system using the slot number (like a token or something). When the job finishes, it releases the number.
Is it possible in Jenkins? In other words, the Jenkins needs to maintain a small integer array for all parallel jobs. Whenever a job asks for a "slot" number, it finds a free number in the array and lock it up.
I Googled it and found a Jenkins plugin called "lockable resource plugin" (Jenkins - How to handle concurrent jobs that use a limited resource pool?), but it can only do "semaphore-like" resource management, not enough for my case. I not only need to know if the resource is used up or not, but also need to know which one is available at the moment.
Thank you guys!!