目前,我正在使用fastlane在本地gitlab运行程序上构建一个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}"这个站点上有很多关于快速车道和身份验证(如这 )的答案,但它们主要关注accounts,而不是企业帐户。目前,我正在遵循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...我的问题是:是否可以判断这个命令是否需要用户输入,这样我就可以退出命令,然后手动刷新会话?
发布于 2021-11-15 20:59:15
快车道中的非交互模式
将环境变量SPACESHIP_ONLY_ALLOW_INTERACTIVE_2FA设置为true,这将只允许交互式环境中的2FA提示符。另外,将FASTLANE_IS_INTERACTIVE设置为false,以告诉fastlane您不能与它交互。
variables:
SPACESHIP_ONLY_ALLOW_INTERACTIVE_2FA: "true"
FASTLANE_IS_INTERACTIVE: "false"这些环境变量的组合应该会引发错误,而不是提示2FA。
请参见:
一般地处理交互式提示
但要回答一个更普遍的问题:“如果程序正在等待输入,您可以退出它吗?”
据我所知,您无法笼统地确定程序是否正在读取stdin。但是,可以这样做的一种方法是查看输入提示符文本的命令的stdout。在您的例子中,您可以查找文本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 scripthttps://stackoverflow.com/questions/69980266
复制相似问题