Skip to content

Instantly share code, notes, and snippets.

@gaelfoppolo
Created February 10, 2021 14:51
Show Gist options
  • Save gaelfoppolo/2b9de9e0722234683e27ba6c0dff35d4 to your computer and use it in GitHub Desktop.
Save gaelfoppolo/2b9de9e0722234683e27ba6c0dff35d4 to your computer and use it in GitHub Desktop.
Auto-setting FASTLANE_SESSION on CI
lane :retrieve_fastlane_session do
# runs shell
# this needs SPACESHIP_SKIP_2FA_UPGRADE=1 flag
spaceauth_output = `bundle exec fastlane spaceauth`
# regex the output for the value we need
fastlane_session_regex = %r{Pass the following via the FASTLANE_SESSION environment variable:\n(?<session>.+)\n\n\nExample:\n.+}
new_session = nil
if match = spaceauth_output.match(fastlane_session_regex)
# strip out the fancy formatting
new_session = match[:session].gsub("\e[4m\e[36m", "").gsub("\e[0m\e[0m", "")
end
# yell and quit if unable to parse out session from spaceauth output
if new_session.nil?
puts "Unable to obtain new FASTLANE_SESSION via fastlane spaceauth"
exit 1
else
ENV['FASTLANE_SESSION'] = new_session
end
end
@gaelfoppolo
Copy link
Author

The recommanded way now is to use the App Store Connect API Key.
But if you can't and want to disable 2FA for now, you can try to set SPACESHIP_SKIP_2FA_UPGRADE=1 in your env. Not sure it works to be honest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment