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
運行結果: