1. 背景
iOS App发版,手动上传流程如下:
1、 Jenkins构建IPA包
2、 从Jenkins下载IPA到本地端
3、 使用有上传权限的Apple Id登录Transporter,选择IPA包上传
手动上传问题:
1、 流程长,耗费时间久
2、 人工操作,有出错概率
3、 操作门槛高(非IOS开发同学无法上传),需要专人才能上传
为解决以上问题,将自动上传脚本(使用xcrun altool)集成到Jenkins中
2. 使用xcrun altool验证/上传IPA包
在Jenkins机器上使用xcrun altool 验证IPA
xcrun altool --validate-app -f Release_XXX_20210508.ipa -t ios --apiKey 905X70Y19V --apiIssuer 00000000-1111-2222-3333-adef2be67000 --verbose
遇到问题,报错信息如下
2021-05-08 10:40:28.608 altool[61907:1253281] *** Error: code -1011 (Failed to authenticate for session: (
"Error Domain=ITunesConnectionAuthenticationErrorDomain Code=-26000 \"The server returned an invalid response. This may indicate that a network proxy is interfering with communication, or that Apple servers are having issues. Please try your request again later.\" UserInfo={NSLocalizedRecoverySuggestion=The server returned an invalid response. This may indicate that a network proxy is interfering with communication, or that Apple servers are having issues. Please try your request again later., NSLocalizedDescription=The server returned an invalid response. This may indicate that a network proxy is interfering with communication, or that Apple servers are having issues. Please try your request again later., NSLocalizedFailureReason=App Store operation failed.}"
) Authentication failed.)
3. 分析问题
看报错提示,可能是如下2个问题引起
1、使用了代理
2、苹果服务器抽风
4. 解决问题
4.1 检查是否开启代理
检查Jenkins机器,发现开启了科学上网工具,遂关闭科学上网工具,并检查网络--高级–代理,确认没有设置代理
再次在shell中运行xcrun altool 验证IPA
xcrun altool --validate-app -f Release_XXX_20210508.ipa -t ios --apiKey 905X70Y19V --apiIssuer 00000000-1111-2222-3333-adef2be67000 --verbose
仍然是相同报错,排除使用代理引起的问题,只剩下另外一种可能性:苹果服务器抽风
4.2 检查苹果服务器是否抽风
使用本地机器,使用相同的apiKey apiIssuer 密钥文件,正常可以验证、上传到App Store,本地机器多次尝试都是正常的,而在Jenkis机器上一直是报错(ITunesConnectionAuthenticationErrorDomain Code=-26000),看来苹果服务器没问题。
百思不得其解,o(╯□╰)o
查看stackoverflow,一阵搜索,再次检查apiKey、apiIssuer、密钥文件路径,发现均是正确的。
万般无奈下,试了下重启大法,发现仍未解决问题。
4.3 转机
偶然间使用Jenkins 构建包,发现Jenkins机器时间比本地时间快10分钟左右,如图第一图为Jenkins机器,第二图图为本地机器
咦,会不会是这个搞得鬼,抱着试一试的想法,将Jenkins机器日期与时间设置为:自动设置日期与时间
再次在shell中运行xcrun altool 验证IPA
xcrun altool --validate-app -f Release_XXX_20210508.ipa -t ios --apiKey 905X70Y19V --apiIssuer 00000000-1111-2222-3333-adef2be67000 --verbose
发现正常验证IPA,然后在Jenkins再次构建包,发现正常验证和上传IPA、问题解决,泪目~~