Update Xcode with fastlane and Jenkins

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:
1 2 3 4 5 6 7 8 9 10 11 12 |
desc "Install/Update Xcode" lane :install_xcode do |options| # Fetch all available Xcode versions sh("xcversion update") # List all available Xcode versions sh("xcversion list") # Get version from parameter or prompt version = options[:xcode_version] || prompt(text: "Enter the version: ") xcode_install(version: version) end |
So we can pass the version as a parameter:
If not, we get the 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:
1 2 3 4 |
#!/bin/bash -l bundle update echo ${SUDO} | sudo -SE bundle exec fastlane ios install_xcode xcode_version:"${VERSION}" |
Now we can update Xcode in Jenkins:
Recent posts

July 2021
Eberhard Mayer
JIB – Build Docker images for your Java Application without a Docker Daemon

March 2021
Constantin Weißer & Dominik Pabst
Understanding Infrastructure as Code (IaC) in less than 10 minutes

August 2019
Mirna Alaisami
CI/CD Series - Part 2: How to build a CI/CD pipeline using Bitbucket, Docker & Kubernetes?...

June 2019
Mirna Alaisami
CI/CD Series - Part 1: How to build a CI/CD pipeline using Jenkins, Docker & Kubernetes? (...

June 2019
Thorsten Jakoby
Storing certificates in Git ?

March 2019
Fabian Warthenpfuhl
Grafana Data Source Provisioning
Comment article