Monday, April 11, 2016

[Jenkins] Install Xcode command line tools over SSH

  1. If you don't have a free Apple developer account, register for one
  2. Download the "Command Line Tools for Xcode" appropriate for your version of OSX
    For me, that was "Command Line Tools (OS X Mountain Lion) for Xcode - April 2014"
  3. Copy the dmg file to your remote
    In the following command, I'm using scp to securely copy the file from my local computer to the remote named remote
    $ scp ~/Downloads/command_line_tools_for_osx_mountain_lion_april_2014.dmg remote:Downloads/
  4. ssh to your remote
    $ ssh remote
  5. mount the dmg file on the remote
    Here, I'm using hdiutil to mount the image
    $ hdiutil attach ~/Downloads/command_line_tools_for_osx_mountain_lion_april_2014.dmg
  6. install the package contained in the dmg
    Here, installer must be run with sudo because this package needs to be installed on the root file system
    $ cd /Volumes/Command\ Line\ Tools\ \(Mountain\ Lion\)
    $ sudo installer -pkg Command\ Line\ Tools\ \(Mountain\ Lion\).mpkg -target /
  7. unmount the dmg file
    $ hdiutil detach /Volumes/Command\ Line\ Tools\ \(Mountain\ Lion\)
  8. delete the dmg file from the remote; optional
    I see no purpose keeping it around, but you can if you want.
    $ rm ~/Downloads/command_line_tools_for_osx_mountain_lion_april_2014.dmg
  9. Use the below to agree to the Xcode/iOS license:
    sudo xcodebuild -license

No comments:

Post a Comment