在 MAC 上使用 Appium+Jenkins+maven+testng 运行自动化测试,发现启动之后很快服务器就异常,但是如果手动在终端输入:


appium &
或者
appium --session-override -a 127.0.0.1 -p 4723 --log ~/jenkins/appium.log &

是可以正常启动服务,然后通过 jenkins 运行自动化测试。

写在 jenkins shell 脚本中:

appium --session-override -a 127.0.0.1 -p 4723 --log ~/jenkins/appium.log &
sleep 2m

就会抛出异常。

环境:

Appium Server version: 1.8.1
Desktop OS/version used to run Appium:10.13.5
Node.js version (unless using Appium.app|exe):v10.7.0
Mobile platform/version under test:11.4
Real device or emulator/simulator:iPhone 6P real device
Appium CLI or Appium.app|exe:Appium.app

Jenkins 控制台异常:

35m[Appium]�[39m Welcome to Appium v1.8.1
�[35m[Appium]�[39m Non-default server args:
�[35m[Appium]�[39m address: 127.0.0.1
�[35m[Appium]�[39m sessionOverride: true
�[35m[Appium]�[39m log: /Users/caoying/jenkins/appium.log
�[35m[Appium]�[39m Appium REST http interface listener started on 127.0.0.1:4723
Process leaked file descriptors. See https://jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors for more information
Parsing POMs
Established TCP socket on 56929
[MailIOSUITest] $ /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/bin/java -cp /Users/caoying/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.12-alpha-1.jar:/Users/caoying/apache-maven-3.5.3/boot/plexus-classworlds-2.5.2.jar:/Users/caoying/apache-maven-3.5.3/conf/logging jenkins.maven3.agent.Maven35Main /Users/caoying/apache-maven-3.5.3 /Users/caoying/jenkins/tomcat/webapps/jenkins/WEB-INF/lib/remoting-3.17.jar /Users/caoying/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.12-alpha-1.jar /Users/caoying/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 56929
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f /Users/caoying/jenkins/jenkins_home/workspace/MailIOSUITest/pom.xml clean package
[INFO] Scanning for projects...
[INFO]
[INFO] -------------< com.netease.mailmaster.test:MailIOSUITest >--------------
[INFO] Building MailIOSUITest 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MailIOSUITest ---
[INFO] Deleting /Users/caoying/jenkins/jenkins_home/workspace/MailIOSUITest/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MailIOSUITest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/caoying/jenkins/jenkins_home/workspace/MailIOSUITest/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ MailIOSUITest ---
[INFO] Compiling 8 source files to /Users/caoying/jenkins/jenkins_home/workspace/MailIOSUITest/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MailIOSUITest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/caoying/jenkins/jenkins_home/workspace/MailIOSUITest/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ MailIOSUITest ---
[INFO] Compiling 5 source files to /Users/caoying/jenkins/jenkins_home/workspace/MailIOSUITest/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ MailIOSUITest ---
[INFO] Surefire report directory: /Users/caoying/jenkins/jenkins_home/workspace/MailIOSUITest/target/surefire-reports

appium.log:

Appium Server is start but as soon as possible failed.

appium.log:2018-07-25 02:19:35:355 - info: [Appium] Welcome to Appium v1.8.1
2018-07-25 02:19:35:357 - info: [Appium] Non-default server args:
2018-07-25 02:19:35:358 - info: [Appium] address: 127.0.0.1
2018-07-25 02:19:35:358 - info: [Appium] sessionOverride: true
2018-07-25 02:19:35:358 - info: [Appium] log: /Users/caoying/jenkins/appium.log
2018-07-25 02:19:35:394 - info: [Appium] Appium REST http interface listener started on 127.0.0.1:4723
2018-07-25 02:20:00:012 - info: [HTTP] --> POST /wd/hub/session
2018-07-25 02:20:00:013 - info: [HTTP] {"capabilities":[{"desiredCapabilities":{"app":"/Users/caoying/MailMaster/mail.ipa","no_reset":false,"appiumVersion":"1.8.0","platformVersion":"11.4","xcodeOrgId":"7ASX6BDY42","automationName":"XCUITest","platformName":"iOS","udid":"6cd169b2c30282316829f9cf25880497d1abfaea","device
":"iPhone 6p","xcodeSigningId":"iPhone Developer"}},{"requiredCapabilities":{}}],"desiredCapabilities":{"app":"/Users/caoying/MailMaster/mail.ipa","no_reset":false,"appiumVersion":"1.8.0","platformVersion":"11.4","xcodeOrgId":"7ASX6BDY42","automationName":"XCUITest","platformName":"iOS","udid":"6cd169b2c30282316829f9cf25880497d1abfaea","deviceName":"iPhone 6p","xcodeSigningId":"iPhone Developer"},"requiredCapabilities":{}}
2018-07-25 02:20:00:015 - info: [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/caoying/MailMaster/mail.ipa","no_reset":false,"appiumVersion":"1.8.0","platformVersion":"11.4","xcodeOrgId":"7ASX6BDY42","automationName":"XCUITest","platformName":"iOS","udid":"6cd169b2c30282316829f9cf25880497d1abfaea","deviceName":"iPhone 6p","xcodeSigningId":"iPhone Developer"},{},[{"desiredCapabilities":{"app":"/Users/caoying/MailMaster/mail.ipa","no_reset":false,"appiumVersion":"1.8.0","platformVersion":"11.4","xcodeOrgId":"7ASX6BDY42","automationName":"XCUITest","platformName":"iOS","udid":"6cd169b2c30282316829f9cf25880497d1abfaea","deviceName":"iPhone 6p","xcodeSigningId":"iPhone Developer"}},{"requiredCapabilities":{}}]]
2018-07-25 02:20:00:016 - info: [debug] [BaseDriver] Event 'newSessionRequested' logged at 1532485200016 (10:20:00 GMT+0800 (中国标准时间))
2018-07-25 02:20:00:019 - info: [Appium] Creating new XCUITestDriver (v2.87.0) session
2018-07-25 02:20:00:020 - info: [Appium] Capabilities:
2018-07-25 02:20:00:025 - info: [Appium] app: /Users/caoying/MailMaster/mail.ipa
2018-07-25 02:20:00:025 - info: [Appium] no_reset: false
2018-07-25 02:20:00:025 - info: [Appium] appiumVersion: 1.8.0
2018-07-25 02:20:00:025 - info: [Appium] platformVersion: 11.4
2018-07-25 02:20:00:026 - info: [Appium] automationName: XCUITest
2018-07-25 02:20:00:026 - info: [Appium] platformName: iOS
2018-07-25 02:20:00:026 - info: [Appium] udid: 6cd169b2c30282316829f9cf25880497d1abfaea
2018-07-25 02:20:00:026 - info: [Appium] deviceName: iPhone 6p
2018-07-25 02:20:00:026 - info: [Appium] xcodeSigningId: iPhone Developer
2018-07-25 02:20:00:030 - info: [debug] [BaseDriver] Creating session with MJSONWP desired capabilities: {"app":"/Users/caoying/Mail...
2018-07-25 02:20:00:038 - warn: [BaseDriver] The following capabilities were provided, but are not recognized by appium: no_reset, appiumVersion.
2018-07-25 02:20:00:041 - info: [BaseDriver] Session created with session id: 6b80d490-a4a0-4a4c-9816-8e54c5c9e76f
2018-07-25 02:20:00:085 - error: uncaughtException: write EPIPE date=Wed Jul 25 2018 10:20:00 GMT+0800 (中国标准时间), pid=6512, uid=501, gid=20, cwd=/Users/caoying/jenkins/jenkins_home/workspace/MailIOSUITest, execPath=/usr/local/Cellar/node/10.7.0/bin/node, version=v10.7.0, argv=[/usr/local/Cellar/node/10.7.0/bin/node, /usr/local/bin/appium, --session-override, -a, 127.0.0.1, -p, 4723, --log, /Users/caoying/jenkins/appium.log], rss=90505216, heapTotal=67457024, heapUsed=59149128, external=168880, loadavg=[2.599609375, 2.2080078125, 2.1865234375], uptime=131651, trace=[column=14, file=net.js, function=WriteWrap.afterWrite, line=836, method=afterWrite, native=false], stack=[Error: write EPIPE, at WriteWrap.afterWrite (net.js:836:14)]

又遇到的同学吗?求帮助!


↙↙↙阅读原文可查看相关链接,并与作者交流