How can I get Xcode 5 to run iOS unit tests on a Jenkins slave?

后端 未结 4 995
迷失自我
迷失自我 2020-12-14 04:09

We\'ve been using Jenkins with the Xcode plugin to run continuous integration of our iOS applications including automatic execution and reporting of the unit tests. This wor

相关标签:
4条回答
  • 2020-12-14 04:33

    Try starting your jenkins slave from a standard terminal on your Mac slave, not from the master using SSH.

    0 讨论(0)
  • 2020-12-14 04:36

    What @GBegen said is correct and I used to do that before as well - Run the simulator and exit VNC without logging out, but that was not reliable. What I do now is to have a script that actually launches the simulator if it is not running. With Xcode 5 that broke as well, but I fixed it by adding the jenkins user to the admin group.

    0 讨论(0)
  • 2020-12-14 04:54

    See GBegen and coffeebreaks' answers. When the Jenkins is secured, use the alternative command line to start it from a screen share/VNC terminal session is

    java -jar slave.jar -jnlpUrl http://jenkins-master:port/computer/jenkins-slave/slave-agent.jnlp -secret XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    
    0 讨论(0)
  • 2020-12-14 04:55

    Based on coffeebreaks' answer, I've come up with a full solution.

    First of all, the Mac slave cannot be launched with SSH and must be launched manually using an interactive session and then left logged in at all times. In my situation, the slave is actually headless, so this is a further complication.

    Here are the steps I used to get this all operational.

    1. Create a new slave node on the Jenkins master configured with a unique label (I chose "xcode-unittests") and launch method set to "Launch slave agents via Java Web Start).

    2. Login via screen sharing (VNC) to the Mac slave and start the slave agent. In my case, I could not get the slave to launch from the browser, probably because my browser did not have the necessary Java plug-in for running applets. I therefore used the command line javaws http://{jenkins-host}/computer/{slave-name}/slave-agent.jnlp. To make this a bit more robust, I configured this command to automatically run every time I login to the machine interactively, under System Preferences, Users & Groups, Login Items.

    3. Quit Screen Sharing without logging out of the Mac slave. This keeps the interactive session running the slave agent alive, even though nobody is actually using the machine.

    In order for the unit tests to run without prompting a user, I also had to run sudo DevToolsSecurity -enable on the Mac slave. This allows Xcode to interact with the iOS Simulator without interactively asking for permission to do so each time.

    If the slave machine is ever rebooted, someone must login to the Mac slave to get the slave agent to run again. For that reason, I also left my SSH-based slave active as well. I split my Jenkins jobs into separate jobs for building the apps and running the unit tests. The jobs for building the apps are configured to run on the SSH-based slave, and the jobs for running the unit tests are configured to run on the interactive slave node described above. That way, if the interactive slave goes down, only the unit tests are affected, not the product builds.

    0 讨论(0)
提交回复
热议问题