STF(Device Farmer)多设备管理平台
github地址:https://github.com/DeviceFarmer/stf
填坑 :由于openstf停止维护,不支持Android 10,所以升级为Device Farmer
openstf支持的Android版本: Supports versions 2.3.3 (SDK level 10) to 9.0 (SDK level 28)
Device Farmer支持的Android版本:Supports versions 2.3.3 (SDK level 10) to 10 (SDK level 29)
一、安装部署
-
依赖
- Node.js 8.x required (some dependencies don't support newer versions)
- ADB properly set up
- RethinkDB >= 2.2
- CMake >= 3.9 (for node-jpeg-turbo)
- GraphicsMagick (for resizing screenshots)
- ZeroMQ libraries installed
- Protocol Buffers libraries installed
- yasm installed (for compiling embedded libjpeg-turbo)
- pkg-config so that Node.js can find the libraries
-
安装
#在Mac OS上,您可以使用homebrew安装大多数依赖项:
brew install rethinkdb graphicsmagick zeromq protobuf yasm pkg-config
#了解下自己的node版本和npm的版本
npm version
#解决好***问题,搞不定就用cnpm,安装之前先卸载为佳,因为npm bug挺多,会误判一些lib
#npm uninstall -g stf
#rm -rf /usr/local/lib/node_modules/stf/
cnpm install -g @devicefarmer/stf
-
常见的坑
- node 版本不要太新,最好使用 LTS 版本 (我从11.x降级为了8.x)
- 更新node版本后原有的依赖需要重新编译
- 权限问题,⽤户和组的权限都必须设置正确
- npm⾃⾝在下载依赖的时候会有bug(下载太慢,容易出错,最终我卸载后用cnpm重装)
-
启动
rethinkdb --http-port 8081 &
指定port,防止和Jenkins等端口冲突
stf local --public-ip <your_internal_network_ip_here> &
-
停止进程
ps -ef | grep stf/lib | awk '{print $2}' | xargs kill -9
二、使用
使用和配置文档:https://github.com/openstf/stf/wiki
rethinkdb地址:http://localhost:8081/
stf地址:http://100.84.84.225:7100/#!/devices
三、API
api文档:https://github.com/DeviceFarmer/stf/blob/master/doc/API.md
token: 44afa160d27b47e8b3513ecabcbe923208ed469a5f644629b006cea9b98f7cbf
- 举个栗子:获取设备列表
curl -H "Authorization: Bearer 44afa160d27b47e8b3513ecabcbe923208ed469a5f644629b006cea9b98f7cbf" http://100.84.86.70:7100/api/v1/devices
mac安装jq,让json格式化显示:brew install jq
curl -H "Authorization: Bearer 44afa160d27b47e8b3513ecabcbe923208ed469a5f644629b006cea9b98f7cbf" http://100.84.84.225:7100/api/v1/devices | jq .
至此:可以管理Android 2.3.3~Android 10的手机了
四、持续集成
1.在stf中生成stf access token
2.jenkins安装stf插件
3.配置STF Access Token
4.配置jenkins job
运行结果: