从jenkins运行测试时,Appium无法启动iOS模拟器。仪器已退出,代码为255

从jenkins运行测试时,Appium无法启动iOS模拟器。仪器已退出,代码为255,ios,maven,jenkins,instruments,appium-ios,Ios,Maven,Jenkins,Instruments,Appium Ios,我目前正在使用Appium为iOS构建一个测试自动化框架。在我的框架中,我在测试套件启动之前从代码内部启动Appium服务器(@BeforeSuite) 当我使用以下命令手动运行测试时: mvn清洁测试#。。。依此类推Appium能够启动模拟器并正常启动测试。但当我使用Jenkins开始测试时,目标和选项都是一样的,就像在终端上一样,它不起作用,只能停留在凝视模拟器上 以下是我的Appium服务器脚本: #!/bin/bash NODE='/Applications/Appium.app/Con

我目前正在使用Appium为iOS构建一个测试自动化框架。在我的框架中,我在测试套件启动之前从代码内部启动Appium服务器(
@BeforeSuite

当我使用以下命令手动运行测试时:
mvn清洁测试#。。。依此类推
Appium能够启动模拟器并正常启动测试。但当我使用Jenkins开始测试时,目标和选项都是一样的,就像在终端上一样,它不起作用,只能停留在凝视模拟器上

以下是我的Appium服务器脚本:

#!/bin/bash
NODE='/Applications/Appium.app/Contents/Resources/node/bin/node'
APPIUM='/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js'
PORT=5000
ADDR=127.0.0.1
LOGDIR=~/log
LOGFILE=$LOGDIR/appium.log
DEVICE=$(idevice_id -l |head -1)
mkdir -p $LOGDIR
function startAppium() {
    SCRIPT="$NODE $APPIUM"
    SCRIPT="$SCRIPT --address $ADDR \
        --port $PORT \
        --native-instruments-lib \
        --session-override \
        --backend-retries 10 \
        --debug-log-spacing \
        --full-reset \
        --debug-log-spacing \
        --command-timeout 90 \
        -g $LOGFILE \
        --launch-timeout 500000"
    echo "Running: $SCRIPT"

    $SCRIPT >> /dev/null &

}
startAppium 2>/dev/null >>/dev/null &
sleep 5
以下是从jenkins开始尝试启动仪器时的Appium日志片段:

2016-02-25 09:56:03:175 - info: [debug] Starting instruments
2016-02-25 09:56:03:183 - info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
2016-02-25 09:56:03:184 - info: Launching instruments
2016-02-25 09:56:03:204 - info: [debug] Attempting to run app on iPhone 5 (9.0)
2016-02-25 09:56:03:205 - info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w "iPhone 5 (9.0)" /Users/Shared/Jenkins/AUT/iOS/Live-release.app -e UIASCRIPT "/Users/Shared/Jenkins/Library/Application Support/appium/bootstrap/bootstrap-f062718992d59810.js" -e UIARESULTSPATH /tmp/appium-instruments
2016-02-25 09:56:03:205 - info: [debug] And extra without-delay env: {}
2016-02-25 09:56:03:205 - info: [debug] And launch timeouts (in ms): {"global":500000}
2016-02-25 09:56:03:986 - info: [debug] [INST] Waiting for device to boot...
2016-02-25 09:56:34:536 - info: [debug] [INST STDERR] Instruments Usage Error : Timed out waiting for device to boot: "iPhone 5 (9.0)"
2016-02-25 09:56:34:546 - info: [debug] [INSTSERVER] Instruments exited with code 255
2016-02-25 09:56:34:546 - info: [debug] Killall instruments
2016-02-25 09:56:34:548 - info: [debug] Instruments crashed on startup
2016-02-25 09:56:34:548 - info: [debug] Attempting to retry launching instruments, this is retry #1
2016-02-25 09:56:34:549 - info: [debug] Killall iOS Simulator
2016-02-25 09:56:39:554 - info: Launching instruments
2016-02-25 09:56:39:555 - info: [debug] Attempting to run app on iPhone 5 (9.0)
...
and so on...
每次Appium尝试重新启动模拟器时的system.log输出:

Feb 25 16:56:39 --- last message repeated 1 time ---
Feb 25 16:56:39 MyMac-Mac-mini.local instruments[27594]: Failed to initialize IconCache named: com.apple.iconservices with error: Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." (connection to service named com.apple.iconservices) UserInfo=0x7fc51bc29af0 {NSDebugDescription=connection to service named com.apple.iconservices}
Feb 25 16:56:39 MyMac-Mac-mini.local instruments[27594]: Error returned from iconservicesagent: Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." (connection to service named com.apple.iconservices) UserInfo=0x7fc51be0c8a0 {NSDebugDescription=connection to service named com.apple.iconservices}
Feb 25 16:56:39 MyMac-Mac-mini com.apple.xpc.launchd[1] (com.apple.StreamingUnzipService): The _DirtyJetsamPriority key is not available on this platform.
Feb 25 16:56:39 MyMac-Mac-mini com.apple.xpc.launchd[1] (com.apple.StreamingUnzipService): The _DirtyJetsamMemoryLimit key is not available on this platform.
Feb 25 16:56:39 MyMac-Mac-mini com.apple.xpc.launchd[1] (com.apple.imfoundation.IMRemoteURLConnectionAgent): The _DirtyJetsamMemoryLimit key is not available on this platform.
Feb 25 16:56:39 MyMac-Mac-mini com.apple.xpc.launchd[1] (com.apple.StreamingUnzipService): The _DirtyJetsamPriority key is not available on this platform.
Feb 25 16:56:39 MyMac-Mac-mini com.apple.xpc.launchd[1] (com.apple.StreamingUnzipService): The _DirtyJetsamMemoryLimit key is not available on this platform.
Feb 25 16:56:39 MyMac-Mac-mini.local com.apple.SecurityServer[80]: Session 100074 created
Feb 25 16:56:39 MyMac-Mac-mini.local com.apple.SecurityServer[80]: Killing auth hosts
Feb 25 16:56:39 MyMac-Mac-mini.local com.apple.SecurityServer[80]: Session 100073 destroyed
Feb 25 16:56:39 MyMac-Mac-mini.local instruments[27594]: DTServiceHubClient: connected to server (singleton pid: 27595, initial pid: 27595)
Feb 25 16:56:40 MyMac-Mac-mini.local instruments[27594]: enumerate proxied devices: true
Feb 25 16:56:40 MyMac-Mac-mini com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.system): Caller not allowed to perform action: instruments.27594, action = service submission, code = 1: Operation not permitted, uid = 247, euid = 247, gid = 1, egid = 1, asid = 100003
Feb 25 16:56:50 MyMac-Mac-mini.local mds[61]: (DiskStore.Normal:2382) d001 1.000014
我对
系统上的日志很好奇。日志
不允许调用方执行操作:instruments.27594,操作=服务提交,代码=1:不允许操作,uid=247,euid=247,gid=1,egid=1,asid=100003

从Jenkin和terminal启动maven脚本时是否有不同的权限

仅供参考:Jenkins是由当前登录用户(Jenkins)启动的,当我检查它也是同一用户时,进程所有者也是

我还尝试启动appium日志中提供的命令:

/Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w "iPhone 5 (9.0)" /Users/Shared/Jenkins/AUT/iOS/Live-release.app -e UIASCRIPT "/Users/Shared/Jenkins/Library/Application Support/appium/bootstrap/bootstrap-f062718992d59810.js" -e UIARESULTSPATH /tmp/appium-instruments
我尝试手动运行它,也从jenkins内部运行,当在终端上手动启动时,模拟器正常启动,但当脚本从jenkins运行时,它不会启动

系统信息:

  • OSX 10.10.5

  • XCode版本:7.2

  • XCode命令行工具路径:
    /Applications/XCode.app/Contents/Developer

  • 仪器,版本7.2(59503)

  • Appium版本:1.4.13(最新Appium)

  • 詹金斯版本:詹金斯版本。1.634

任何线索或答案都会非常有用


谢谢。

您找到解决方法了吗?没有,我刚找到解决方法。。。我只需在这些用户上创建一个普通用户,并启用开发者配置,然后在用户登录时启动jenkins。。这将使启动jenkins的用户与启动模拟器的用户相同。