Lrenger semigo
Lrenger semigo

Reputation: 243

Error when attempting to run UI automation script from jenkins

I am using Xcode 6.1. And i need to run a UI automation script from jenkins as a post build action. The command that i use is shown below.

instruments -t $TRACETEMPLATE -w $DEVICE $APP_PATH -e UIASCRIPT $SCRIPT -e UIARESULTSPATH $RESULTS_PATH | grep "<"  > test-reports/test-results.xml

When i run that the following error is thrown by jenkins.

Failed to authorize rights (0x1) with status: -60007. 2014-11-12 16:31:30.685 instruments[488:2607] -[XRSimulatorDevice prepareConnection:]: Unable to authorize simulated daemon (99637): 8 Instruments Trace Error : Target failed to run: Permission to debug com.test.app was denied.

Any help is much appreciated.

Upvotes: 12

Views: 1070

Answers (3)

quellish
quellish

Reputation: 21244

  1. The user that invokes Instruments must have developer permissions. The user must be in the _developer group.

  2. Security permissions allowing the user to access Instruments must be set. See the man page for DevToolsSecurity

  3. The user must be logged in to a window server to use the simulator. How to do this will depend somewhat on your Jenkins and OS configuration for that user. In older versions of MacOS creating an SSH connection back into the machine and running Instruments through that connection typically worked. YMMV.

Note that any of the above steps escalates the rights for the Jenkins user, which was security implications.

Upvotes: 1

Esenbek Kydyr uulu
Esenbek Kydyr uulu

Reputation: 1623

I also got this error message. Moving service from LaunchDaemons to LaunchAgents didn't solve the problem. My solution was as following:

  1. remove the service by deleting /Library/LaunchAgents/org.jenkins-ci.plist file
  2. create an iOS application using Automator tool. (Which I think exists by default):

    • I chose "Library" -> "Utilities" -> "Shell Script".
    • Enter the content of /Library/Application Support/Jenkins/jenkins-runner.sh.
    • Put export JENKINS_HOME=/path/to/jenkins at the top.
    • Save the app somewhere
  3. Go to Preferences -> Users & Groups -> choose your user -> Add the saved app.

This way, jenkins is run as an application after login and it has all the privilages of any other application.

Upvotes: 0

sv_lane
sv_lane

Reputation: 3089

I got an almost identical error message to yours, and it seemed to be because when Jenkins is launched as a Launch Daemon, it doesn't have access to the screen, even if you log in as "jenkins".

I found the solution from reading this discussion: https://issues.jenkins-ci.org/browse/JENKINS-14421

You can either launch Jenkins from Terminal with java -jar jenkins.war, or you can create a Launch Agent, which runs as the logged-in user and has access to the user's screen.

I achieved the latter solution by moving /Library/LaunchDaemons/org.jenkins-ci.plist to /Library/LaunchAgents/org.jenkins-ci.plist and removing the UserName key and value from the plist. Now Jenkins doesn't start automatically when I boot the machine, but it does start when I log into the desktop, which is required for running UI Automation tests anyway.

It appears that Jenkins still can't actually launch the Simulator app, but if Simulator is already running, the UI Automation scripts proceed just fine.

Upvotes: 0

Related Questions