问题
Case
I have a Jenkins slave witch run's calabash tests on mobile devices (android, ios). To separate on which machines (the mac for iOS or Linux for Android) the tests is run, I also use the Throttle Concurrent Builds Plug-in. This way I separate between the Android or Mac Jenkins slaves the devices are hooked to.
I use a mapping table and a self written bash script to call a device by name and execute a test on this specific slave. The mapping table map's the name to the device id (or IP for iOS).
The architecture is as follows:
[Master]--(Slave-iOS)---------iPhone6
| |--------------iPhone5
|
|--------(Slave-Android)-----HTCOne
|--------------Nexus
|--------------G4
To hand over the device to the bash script I use the Jenkins Matrix Project Plugin, which lets me create a list of devices and test cases like:
HTCOne Nexus G4
Run x x x
Delete x x x
CreateUser x x x
Sadly this list can only be executed sequentially. Now I also want to build tests on multiple devices in parallel and cross vice versa.
Question
I search for a Jenkins plugin which handles devices allocation. If one trigger needs a specific device it should wait until this one is accessible and the test can be executed. The plugin should integrate with the shell execution in Jenkins.
A big plus would be, if it can be combined with the Matrix Project Plugin!
What I looked into so far:
- Exclusion-Plugin,
- Throttle Concurrent Builds Plug-in, [used to specifiy the slave]
- Locks and Latches plugin, For all the listed ones so far, I don't know how to link them to the matrix configuration and get a device dynamically. I also don't know how to get the locked resource information into my script.
- Port Allocator Plugin, not tested but seems to have the same problem
- External Resource Dispatcher, seem to allocate only one resource and is not finding anything if it is a matrix configuration.
Related questions I found, which helped but didn't solved the problem:
- How to prevent certain Jenkins jobs from running simultaneously?
- Jenkins: group jobs and limit build processors for this group
- Jenkins to not allow the same job to run concurrently on the same node?
- How do I ensure that only one of a certain category of job runs at once in Hudson?
- Disable Jenkins Job from Another Job
回答1:
If Throttle Concurrent Builds Plugin doesn't work as required in your multi-configuration project, try Exclusion Plugin with a dynamic resource name, like: SEMAPHORE_MATRIX_${NODE_NAME}
Then add a Build step "Critical block start" (and an optional "Critical block end" step), which will hold this build block execution until SEMAPHORE_MATRIX_${NODE_NAME} is not in use on any other job, including the current Matrix child jobs.
(... Build steps to be run only when SEMAPHORE_MATRIX_${NODE_NAME} is available ...)
来源:https://stackoverflow.com/questions/31120850/jenkins-multiconfiguration-project-handle-concurrent-device-usage