appium多设备连接,mac终端上执行正常,在Jenkins添加macos节点执行时报错,没有找到解决方法,请教一下大家。是[UiAutomator2] Deleting UiAutomator2 session,appium日志如下:

2021-08-04 14:20:51:125 [Appium] Welcome to Appium v1.21.0
2021-08-04 14:20:51:126 [Appium] Non-default server args:
2021-08-04 14:20:51:127 [Appium] sessionOverride: true
2021-08-04 14:20:51:127 [Appium] logFile: /Users/bignox/PycharmProjects/multi_devices_run/Outputs/appium_server_logs/appium_server_4723.log
2021-08-04 14:20:51:127 [Appium] logTimestamp: true
2021-08-04 14:20:51:127 [Appium] localTimezone: true
2021-08-04 14:20:51:147 [Appium] Appium REST http interface listener started on 0.0.0.0:4723
2021-08-04 14:21:06:529 [HTTP] Request idempotency key: 53f2c62b-560a-4231-89f0-d44b530108bb
2021-08-04 14:21:06:543 [HTTP] → POST /wd/hub/session
2021-08-04 14:21:06:544 [HTTP] {“capabilities”:{“firstMatch”:[{“appium:deviceName”:“J6AXB761J682CP7”,“appium:platformVersion”:“8.1.0”,“platformName”:“Android”,“appium:appPackage”:“com.bloom.selfie.camera.beauty”,“appium:appActivity”:“com.bloom.selfie.camera.beauty.module.main.SplashActivity”,“appium:noReset”:true,“appium:autoGrantPermissions”:true,“appium:automationName”:“UiAutomator2”,“appium:systemPort”:8200}]},“desiredCapabilities”:{“deviceName”:“J6AXB761J682CP7”,“platformVersion”:“8.1.0”,“platformName”:“Android”,“appPackage”:“com.bloom.selfie.camera.beauty”,“appActivity”:“com.bloom.selfie.camera.beauty.module.main.SplashActivity”,“noReset”:true,“autoGrantPermissions”:true,“automationName”:“UiAutomator2”,“systemPort”:8200}}
2021-08-04 14:21:06:545 [W3C] Calling AppiumDriver.createSession() with args: [{“deviceName”:“J6AXB761J682CP7”,“platformVersion”:“8.1.0”,“platformName”:“Android”,“appPackage”:“com.bloom.selfie.camera.beauty”,“appActivity”:“com.bloom.selfie.camera.beauty.module.main.SplashActivity”,“noReset”:true,“autoGrantPermissions”:true,“automationName”:“UiAutomator2”,“systemPort”:8200},null,{“firstMatch”:[{“appium:deviceName”:“J6AXB761J682CP7”,“appium:platformVersion”:“8.1.0”,“platformName”:“Android”,“appium:appPackage”:“com.bloom.selfie.camera.beauty”,“appium:appActivity”:“com.bloom.selfie.camera.beauty.module.main.SplashActivity”,“appium:noReset”:true,“appium:autoGrantPermissions”:true,“appium:automationName”:“UiAutomator2”,“appium:systemPort”:8200}]}]
2021-08-04 14:21:06:546 [BaseDriver] Event ‘newSessionRequested’ logged at 1628058066546 (14:21:06 GMT+0800 (China Standard Time))
2021-08-04 14:21:06:812 [Appium] Appium v1.21.0 creating new AndroidUiautomator2Driver (v1.65.0) session
2021-08-04 14:21:06:812 [Appium] There are no active sessions for cleanup
2021-08-04 14:21:06:815 [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
2021-08-04 14:21:06:815 [BaseDriver] Creating session with W3C capabilities: {
2021-08-04 14:21:06:815 [BaseDriver] “alwaysMatch”: {
2021-08-04 14:21:06:815 [BaseDriver] “platformName”: “Android”,
2021-08-04 14:21:06:815 [BaseDriver] “appium:deviceName”: “J6AXB761J682CP7”,
2021-08-04 14:21:06:815 [BaseDriver] “appium:platformVersion”: “8.1.0”,
2021-08-04 14:21:06:816 [BaseDriver] “appium:appPackage”: “com.bloom. selfie.camera.beauty”,
2021-08-04 14:21:06:816 [BaseDriver] “appium:appActivity”: “com.bloom.selfie.camera.beauty.module.main.SplashActivity”,
2021-08-04 14:21:06:816 [BaseDriver] “appium:noReset”: true,
2021-08-04 14:21:06:816 [BaseDriver] “appium:autoGrantPermissions”: true,
2021-08-04 14:21:06:816 [BaseDriver] “appium:automationName”: “UiAutomator2”,
2021-08-04 14:21:06:816 [BaseDriver] “appium:systemPort”: 8200
2021-08-04 14:21:06:816 [BaseDriver] },
2021-08-04 14:21:06:816 [BaseDriver] “firstMatch”: [
2021-08-04 14:21:06:816 [BaseDriver] {}
2021-08-04 14:21:06:817 [BaseDriver] ]
2021-08-04 14:21:06:817 [BaseDriver] }
2021-08-04 14:21:06:825 [BaseDriver] Session created with session id: 98d2d474-039c-45c8-94a0-bb34f191e3c3
2021-08-04 14:21:06:825 [UiAutomator2] Starting ‘com.bloom.selfie.camera.beauty’ directly on the device
2021-08-04 14:21:06:827 [UiAutomator2] Deleting UiAutomator2 session
2021-08-04 14:21:06:828 [BaseDriver] Event ‘newSessionStarted’ logged at 1628058066828 (14:21:06 GMT+0800 (China Standard Time))
2021-08-04 14:21:06:909 [W3C] Encountered internal error running command: Error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
2021-08-04 14:21:06:909 [W3C] at requireSdkRoot (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-adb/lib/helpers.js:36:11)
2021-08-04 14:21:06:909 [W3C] at Function.createADB (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-adb/lib/adb.js:55:23)
2021-08-04 14:21:06:909 [W3C] at Object.createBaseADB (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-android-driver/lib/android-helpers.js:108:20)
2021-08-04 14:21:06:910 [W3C] at Object.getDeviceInfoFromCaps (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-android-driver/lib/android-helpers.js:193:29)
2021-08-04 14:21:06:910 [W3C] at AndroidUiautomator2Driver.startUiAutomator2Session (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:326:40)
2021-08-04 14:21:06:910 [W3C] at AndroidUiautomator2Driver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:223:18)
2021-08-04 14:21:06:910 [W3C] at processTicksAndRejections (internal/process/task_queues.js:97:5)
2021-08-04 14:21:06:910 [W3C] at AppiumDriver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/lib/appium.js:387:35)
2021-08-04 14:21:06:924 [HTTP] ← POST /wd/hub/session 500 379 ms - 879
2021-08-04 14:21:06:924 [HTTP]
2021-08-04 14:21:09:102 [Appium] Received SIGTERM - shutting down
2021-08-04 14:21:09:108 [Appium] There are no active sessions for cleanup
2021-08-04 14:21:09:111 uncaughtException: write EPIPE
Error: write EPIPE
at afterWriteDispatched (internal/stream_base_commons.js:154:25)
at writeGeneric (internal/stream_base_commons.js:145:3)
at Socket._writeGeneric (net.js:782:11)
at Socket._write (net.js:794:8)
at writeOrBuffer (_stream_writable.js:352:12)
at Socket.Writable.write (_stream_writable.js:303:10)
at Console.log (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/winston/lib/winston/transports/console.js:79:23)
at Console._write (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/winston-transport/index.js:103:17)
at doWrite (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at Console.Writable.write (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js:334:11)
at DerivedLogger.ondata (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/readable-stream/lib/_stream_readable.js:681:20)
at DerivedLogger.emit (events.js:327:22)
at addChunk (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/readable-stream/lib/_stream_readable.js:298:12)
at readableAddChunk (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/readable-stream/lib/_stream_readable.js:280:11)
at DerivedLogger.Readable.push (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/readable-stream/lib/_stream_readable.js:241:10)
2021-08-04 14:21:09:113 uncaughtException: write EPIPE
Error: write EPIPE
at afterWriteDispatched (internal/stream_base_commons.js:154:25)
at writeGeneric (internal/stream_base_commons.js:145:3)
at Socket._writeGeneric (net.js:782:11)
at Socket._write (net.js:794:8)
at writeOrBuffer (_stream_writable.js:352:12)
at Socket.Writable.write (_stream_writable.js:303:10)
at Console.log (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/winston/lib/winston/transports/console.js:51:25)
at Console._write (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/winston-transport/index.js:103:17)
at doWrite (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at Console.Writable.write (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js:334:11)
at DerivedLogger.ondata (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/readable-stream/lib/_stream_readable.js:681:20)
at DerivedLogger.emit (events.js:327:22)
at addChunk (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/readable-stream/lib/_stream_readable.js:298:12)
at readableAddChunk (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/readable-stream/lib/_stream_readable.js:280:11)
at DerivedLogger.Readable.push (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/readable-stream/lib/_stream_readable.js:241:10)

Jenkins添加Macos节点和appium没关系吧。。

脚本在mac上是正常执行的,配置到Jenkins上再执行,启session就出现问题了。mac上的环境变量也配了,找不到问题在哪儿
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
export ANDROID_SDK_ROOT=/Users/bignox/Library/Android/sdk/android-sdk-macosx
export ANDROID_HOME=/Users/bignox/Library/Android/sdk/android-sdk-macosx
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/emulator
export PATH=${PATH}:${ANDROID_HOME}/tools/bin
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/build-tools/29.0.3

在Jenkins上执行脚本之前加个source ~/.bash_profile试试看,

是从这里报错得,这里是说环境变量有问题

谢谢,我试一下

加了 source ~/.bash_profile会报错的,可能里边有其他内容,
我直接把下边的内容加进去就好了,非常感谢
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
export ANDROID_SDK_ROOT=/Users/bignox/Library/Android/sdk/android-sdk-macosx
export ANDROID_HOME=/Users/bignox/Library/Android/sdk/android-sdk-macosx
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/emulator
export PATH=${PATH}:${ANDROID_HOME}/tools/bin
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/build-tools/29.0.3