cowwoc commented on Improvement JENKINS-21237

So... I made a major discovery.

If you want to run a OSX slave that can interact with the GUI, all you need to do is log in that user locally. Meaning, you can:

  1. Launch an SSH connection, try launching the iOS simulator and it will fail.
  2. Log in the user locally
  3. Try launching the iOS simulator from the SSH connection from step 1, and it'll work.

So, for the easiest configuration of an OSX slave I recommend the following:

  1. Launch the slave from SSH as you would Linux (this is the easiest option to configure and maintain)
  2. If you don't need access to the GUI, stop here. Otherwise, do the following:
  3. Enable automatic logins for the Jenkins user as described at http://apple.stackexchange.com/q/43413/21181
  4. Install the Slave Setup plugin
  5. Under "Manage Jenkins -> Configure System -> Slave Setups" add a new entry
  6. Set "setup files directory" to an absolute directory on your Jenkins Master computer, say "/var/jenkins/scripts/osx"
  7. Set "setup script after copy" to:
    chmod u+x prepare-slave.sh
    ./prepare-slave.sh
  8. Create the following file in the scripts directory:
    #!/bin/bash
    /usr/bin/security unlock-keychain -p jenkins-keychain-password
    
    # Wait for the user to log in locally before allowing jobs to run, otherwise iOS simulator will not launch
    TIME_ELAPSED=0
    while true; do
      pgrep -u builds -f -l -q "/System/Library/CoreServices/SystemUIServer\.app/Contents/MacOS/SystemUIServer"
      [ $? -eq 0 ] && break
      ((TIME_ELAPSED++))
      echo "Waiting for \"builds\" to log in locally [$TIME_ELAPSED / 60]..."
      if [ $TIME_ELAPSED -ge 60 ]; then
        exit 1
      fi
      sleep 1
    done
    echo

The script at the end guarantees that the user finishes logging in locally before Jenkins will launch any jobs on the node. I suggest adding this documentation under https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds#Distributedbuilds-Differentwaysofstartingslaveagents

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to