Jenkins 多配置项目处理并发设备使用
Jenkins multiconfiguration project handle concurrent device usage
案例
我有一个 Jenkins slave 运行 在移动设备上的 calabash 测试(android,ios)。为了区分哪个machines(mac代表iOS或Linux代表Android)测试是运行,我还使用节流并发构建插件。通过这种方式,我将设备所连接的 Android 或 Mac Jenkins 奴隶分开。
我使用一个映射 table 和一个自写的 bash 脚本来按名称调用设备并在这个特定的从属设备上执行测试。映射 table 将名称映射到设备 ID(或 iOS 的 IP)。
架构如下:
[Master]--(Slave-iOS)---------iPhone6
| |--------------iPhone5
|
|--------(Slave-Android)-----HTCOne
|--------------Nexus
|--------------G4
为了将设备移交给 bash 脚本,我使用了 Jenkins Matrix 项目插件,它让我创建了一个设备列表和测试用例,例如:
HTCOne Nexus G4
Run x x x
Delete x x x
CreateUser x x x
遗憾的是这个列表只能按顺序执行。现在我也想在多个设备上并行构建测试,反之亦然。
问题
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.
如果能与 Matrix Project Plugin 结合使用就更好了!
到目前为止我调查的内容:
- 排除插件,
- Throttle Concurrent Builds 插件,[用于指定从属]
- Locks and Latches 插件,
到目前为止,对于所有列出的,我不知道如何将它们 link 到矩阵配置并动态获取设备。我也不知道
如何将锁定的资源信息获取到我的脚本中。
- 端口分配器插件,未经测试但似乎有同样的问题
- 外部资源调度程序,似乎只分配一个资源,如果是矩阵配置,则找不到任何资源。
我发现的相关问题,对问题有帮助但没有解决问题:
- 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
如果 Throttle Concurrent Builds Plugin 在您的 多配置项目 中无法按要求工作,请尝试
Exclusion Plugin 使用动态资源名称,例如:SEMAPHORE_MATRIX_${NODE_NAME}
然后添加一个构建步骤 "Critical block start"(和一个可选的 "Critical block end" 步骤),它将保持此构建块执行直到 SEMAPHORE_MATRIX_${NODE_NAME} 不是正在用于任何其他作业,包括当前的 Matrix 子作业。
(...仅当 SEMAPHORE_MATRIX_${NODE_NAME} 可用时构建步骤为 运行...)
案例
我有一个 Jenkins slave 运行 在移动设备上的 calabash 测试(android,ios)。为了区分哪个machines(mac代表iOS或Linux代表Android)测试是运行,我还使用节流并发构建插件。通过这种方式,我将设备所连接的 Android 或 Mac Jenkins 奴隶分开。
我使用一个映射 table 和一个自写的 bash 脚本来按名称调用设备并在这个特定的从属设备上执行测试。映射 table 将名称映射到设备 ID(或 iOS 的 IP)。
架构如下:
[Master]--(Slave-iOS)---------iPhone6
| |--------------iPhone5
|
|--------(Slave-Android)-----HTCOne
|--------------Nexus
|--------------G4
为了将设备移交给 bash 脚本,我使用了 Jenkins Matrix 项目插件,它让我创建了一个设备列表和测试用例,例如:
HTCOne Nexus G4
Run x x x
Delete x x x
CreateUser x x x
遗憾的是这个列表只能按顺序执行。现在我也想在多个设备上并行构建测试,反之亦然。
问题
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.
如果能与 Matrix Project Plugin 结合使用就更好了!
到目前为止我调查的内容:
- 排除插件,
- Throttle Concurrent Builds 插件,[用于指定从属]
- Locks and Latches 插件, 到目前为止,对于所有列出的,我不知道如何将它们 link 到矩阵配置并动态获取设备。我也不知道 如何将锁定的资源信息获取到我的脚本中。
- 端口分配器插件,未经测试但似乎有同样的问题
- 外部资源调度程序,似乎只分配一个资源,如果是矩阵配置,则找不到任何资源。
我发现的相关问题,对问题有帮助但没有解决问题:
- 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
如果 Throttle Concurrent Builds Plugin 在您的 多配置项目 中无法按要求工作,请尝试 Exclusion Plugin 使用动态资源名称,例如:SEMAPHORE_MATRIX_${NODE_NAME}
然后添加一个构建步骤 "Critical block start"(和一个可选的 "Critical block end" 步骤),它将保持此构建块执行直到 SEMAPHORE_MATRIX_${NODE_NAME} 不是正在用于任何其他作业,包括当前的 Matrix 子作业。
(...仅当 SEMAPHORE_MATRIX_${NODE_NAME} 可用时构建步骤为 运行...)