目前我正在使用 fastlane 在本地 gitlab runner 上構建一個 iOS 應用程式。
這是我的問題所關注的腳本部分:
- 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}"
有很多在這個網站有關FASTLANE和驗證答案如這個,但他們主要集中在App Store的連接,而不是企業賬戶。目前,我正在遵循 fastlane檔案中關于在我的 ci 機器上存盤會話的建議。
問題是一個月后會話過期并且 fastlane 命令不斷嘗試通過兩個因素進行身份驗證,導致我在 24 小時內被暫時鎖定在我的帳戶之外進行了太多嘗試。有關 CI 日志,請參見下文。
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...
我的問題是:是否可以判斷此命令是否需要用戶輸入,以便我可以退出命令然后手動重繪 會話?
uj5u.com熱心網友回復:
Fastlane 中的非互動模式
設定環境變數SPACESHIP_ONLY_ALLOW_INTERACTIVE_2FA來true將只允許在2FA互動式環境提示。此外,設定FASTLANE_IS_INTERACTIVE為false告訴 fastlane 您無法與之互動。
variables:
SPACESHIP_ONLY_ALLOW_INTERACTIVE_2FA: "true"
FASTLANE_IS_INTERACTIVE: "false"
這些環境變數的組合應該會導致引發錯誤而不是提示 2FA。
看:
- 持續集成實踐
- 2FA源代碼
一般處理互動式提示
但是要回答更通用的問題:“如果程式正在等待輸入,您是否可以退出它”。
據我所知,您不能一般地確定程式是否正在讀取標準輸入。但是,執行此操作的一種方法可能是查看輸入提示文本的命令的標準輸出。在您的情況下,您可以查找文本Please enter the 6 digit code并在找到后退出。
因此,用于此的 bash 腳本可能如下所示:
prompt="Please enter the 6 digit code"
program_that_might_prompt_for_input > output.txt 2>&1 &
command_pid=$!
sleep 5 # probably a more elegant way to do this
output="$(cat output.txt)"
if grep -q "$prompt" <<< "$output"; then
echo '2FA prompt detected. bailing.' > /dev/stderr
kill $command_pid # if you need to
exit 1
fi
wait # wait for command to finish
# rest of script
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/358076.html
