问题描述
我正在使用以下脚本将ipa发布到appcenter。
ipaPath=<PATH TO MY IPA FILE>
echo "Found ipa at $ipaPath"
if [[ -z ${ipaPath} ]]
then
echo "No ipas were found,skip publishing to App Center"
else
appcenter login
appcenter distribute release \
--group Collaborators \
--file "${ipaPath}" \
--release-notes 'App submission' \
--app <username_or_organization>/<application_identifier> \
--quiet
fi
如果登录失败并且我不想运行distribution命令,我需要退出。如何检查登录状态并处理错误?
解决方法
您可以使用command substitution将appcenter login
的结果捕获到变量中,然后在变量内容中搜索特定的字符串(或缺少字符串)。例如:
reply="$(appcenter login --token ${token})"
if [[ $reply == *"Error"* ]]; then
echo "A problem occurred! ${reply}"
else
appcenter distribute release
...
fi