Currently I am using fastlane to build an iOS app on a local gitlab runner.
Here is the part of the script my question is focused on:
- bundle exec fastlane cert -u ${ENTERPRISE_APPLE_ID}
- bundle exec fastlane sigh -a ${PROVISIONING_PROFILE_IDENTIFIER} username:${ENTERPRISE_APPLE_ID}
- bundle exec fastlane gym --clean --export_method enterprise --output_name "APP-${TAG}"
There is a lot of answers on this site related to fastlane and authentication such as this but they mostly focus on App Store Connect, not enterprise accounts. Currently I am following the suggestions from the fastlane docs about storing a session on my ci machine.
The problem is after a month the session expires and the fastlane command keeps trying to auth via two factor leading to me being temporarily locked out of my account for too many attempts within 24 hours. See below for the CI logs.
18:27:18]: Starting login with user 'my@apple.id'
Available session is not valid any more. Continuing with normal login.
Session loaded from environment variable is not valid. Continuing with normal login.
Two-factor Authentication (6 digits code) is enabled for account 'my@apple.id'
More information about Two-factor Authentication: https://support.apple.com/en-us/HT204915
If you're running this in a non-interactive session (e.g. server or CI)
check out https://github.com/fastlane/fastlane/tree/master/spaceship#2-step-verification
Please enter the 6 digit code you received at +1 (•••) •••-••14:
Requesting session...
Error: Incorrect verification code
Please enter the 6 digit code you received at +1 (•••) •••-••14:
Requesting session...
Error: Incorrect verification code
Please enter the 6 digit code you received at +1 (•••) •••-••14:
Requesting session...
My question is: is it possible to tell if this command is requiring user input so I can just exit the command and then manually refresh the session?