Created
February 10, 2021 14:51
-
-
Save gaelfoppolo/2b9de9e0722234683e27ba6c0dff35d4 to your computer and use it in GitHub Desktop.
Auto-setting FASTLANE_SESSION on CI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
I tried to use this, but it still sends me 2FA to my phone when running on CI.
I have
FASTLANE_USER
andFASTLANE_PASSWORD
set correctly, but this is still a problem. For you it works fine on CI @gaelfoppolo ?