user-icon Michael Ruhl
28. April 2017
timer-icon 2 min

Update Xcode with fastlane and Jenkins

Maintaining Xcode on a CI server has always been a hassle. Over the past we suffered through different solutions, from connection via VNC and updating Xcode with the Mac App Store, to manually downloading Xcode from the Developer Portal.

Luckily there is a RubyGem Xcode-Install to install/update Xcode, and has a comfortable fastlane integration. (We will cover more of fastlane very soon 😉 )

Xcode lane

For our projects we created a lane to update Xcode locally and on CI servers:


 

So we can pass the version as a parameter:
Update Xcode with parameter
If not, we get the prompt:
Update Xcode with prompt

Jenkins Integration

As we already using Jenkins for our other builds, I wanted to create a job for updating Xcode as well.
The only problem, the xcode-install gem requires the user-password during the installation.

I thought of several solutions, but all of them don’t sound really secure:

  • Run Jenkins as root user
  • Allow sudo without password prompt

In the end I found a better solution. It’s possible to pipe the password into sudo and execute fastlane:


 

Now we can update Xcode in Jenkins:
Update xcode job

Comment article