持续集成 Jekins+Appium 做自动化测试,多台手机的时候,如何让 job 可以自动选取可用设备

Shi · 2016年12月05日 · 最后由 不二家 回复于 2017年03月12日 · 1429 次阅读

现在我这里是有多个项目的 job(2-3 个),然后一台机子上我插了 4 台 android 设备,现在想实现 job 运行的时候自动选取可用设备,比如设备 1 现在被 job1 占用了,那么 job2 就在设备 2-4 之间选择,找了好久没找到有插件可以用

共收到 2 条回复 时间 点赞

Lockable Resources Plugin 可以解决你的问题。
链接:https://wiki.jenkins-ci.org/display/JENKINS/Lockable+Resources+Plugin
描述:This plugin allows to define lockable resources (such as printers, phones, computers, etc.) that can be used by builds. If a build requires an resource which is already locked, it will wait for the resource to be free. One can define a lock-priority globally and on a per-job basis.

对于你机子上的 4 台 android 设备,可以手动把它们配置在 Lockable Resources 里。比如以设备序列号做为名字,Label 设定为你的资源池的名字 (比如 Nexus)。如果你想自动的把连接的设备配置进来,可以创建一个上游 job,根据 adb devices -l 的设备列表,更新 Jenkins 配置文件 org.jenkins.plugins.lockableresources.LockableResourcesManager.xml.

<org.jenkins.plugins.lockableresources.LockableResource>
   <name>Serial Number 1</name>
   <description>Functional Testing</description>
   <labels>Google Nexus</labels>
 </org.jenkins.plugins.lockableresources.LockableResource>

label 名字设定成一样,随机可以选取?我配置 slave 的时候,label 名字取一样,job 是可以随机选取 slave 执行的,不知道能否帮到你。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册