即使使用 API 密钥,Fastlane 上传到 App Store 也会在非交互模式下失败

Posted

技术标签:

【中文标题】即使使用 API 密钥,Fastlane 上传到 App Store 也会在非交互模式下失败【英文标题】:Fastlane upload to App Store fails in non-interactive mode even with API key 【发布时间】:2021-04-21 22:22:35 【问题描述】:

我在 GitLab CI 环境中使用 Fastlane。我正在使用 API 密钥并已成功将我的应用上传到 TestFlight。但是,将应用程序上传到 App Store 时会失败。构建成功上传,但在发送元数据后等待响应时失败。以下是相关的sn-ps:

# Fastfile

lane :get_app_store_connect_api_key do
  ensure_env_vars(
    env_vars: [
      'APP_STORE_CONNECT_API_KEY'
    ]
  ) 
  app_store_connect_api_key(
    key_id: "**********",
    issuer_id: "********-****-****-****-************",
    key_content: "#ENV["APP_STORE_CONNECT_API_KEY"]".gsub('\n', '\\n'),
    in_house: false,
  )
end

...


  desc "Push a new release channel build to the App Store."
  lane :release do
  
    build_release()

    appstore(
      api_key: get_app_store_connect_api_key
    )

  end
LOG

[17:22:47]: ----------------------
[17:22:47]: --- Step: appstore ---
[17:22:47]: ----------------------
[17:22:47]: Successfully loaded '/Users/********/builds/qVPSw-s1/0/********/********/client/ios/fastlane/Deliverfile' ????
[17:22:47]: No values defined in './fastlane/Deliverfile'
[17:22:47]: Creating authorization token for App Store Connect API
+--------------------------------------+------------------------+
|                    deliver 2.181.0 Summary                    |
+--------------------------------------+------------------------+
| api_key                              | ********               |
| screenshots_path                     | ./fastlane/screenshots |
| metadata_path                        | ./fastlane/metadata    |
| app_version                          | 1.1.0                  |
| username                             | ********        |
| app_identifier                       | com.********.app       |
| ipa                                  | Runner.ipa             |
| platform                             | ios                    |
| edit_live                            | false                  |
| use_live_version                     | false                  |
| skip_binary_upload                   | false                  |
| skip_screenshots                     | false                  |
| skip_metadata                        | false                  |
| skip_app_version_update              | false                  |
| force                                | false                  |
| overwrite_screenshots                | false                  |
| submit_for_review                    | false                  |
| reject_if_possible                   | false                  |
| phased_release                       | false                  |
| reset_ratings                        | false                  |
| team_id                              | ********|
| dev_portal_team_id                   | ********|
| run_precheck_before_submit           | true                   |
| precheck_default_rule_level          | warn                   |
| ignore_language_directory_validation | false                  |
| precheck_include_in_app_purchases    | true                   |
+--------------------------------------+------------------------+
[17:22:52]: Making sure the latest version on App Store Connect matches '1.1.0'...
[17:22:54]: Successfully set the version to '1.1.0'
[17:22:54]: Loading './fastlane/metadata/en-US/description.txt'...
[17:22:54]: Loading './fastlane/metadata/en-US/keywords.txt'...
[17:22:54]: Loading './fastlane/metadata/en-US/release_notes.txt'...
[17:22:54]: Loading './fastlane/metadata/en-US/support_url.txt'...
[17:22:54]: Loading './fastlane/metadata/en-US/marketing_url.txt'...
[17:22:54]: Loading './fastlane/metadata/en-US/promotional_text.txt'...
[17:22:54]: Loading './fastlane/metadata/en-US/name.txt'...
[17:22:54]: Loading './fastlane/metadata/en-US/subtitle.txt'...
[17:22:54]: Loading './fastlane/metadata/en-US/privacy_url.txt'...
[17:22:54]: Loading './fastlane/metadata/en-US/apple_tv_privacy_policy.txt'...
[17:22:54]: Loading './fastlane/metadata/copyright.txt'...
[17:22:54]: Loading './fastlane/metadata/primary_category.txt'...
[17:22:54]: Loading './fastlane/metadata/secondary_category.txt'...
[17:22:54]: Loading './fastlane/metadata/primary_first_sub_category.txt'...
[17:22:54]: Loading './fastlane/metadata/primary_second_sub_category.txt'...
[17:22:54]: Loading './fastlane/metadata/secondary_first_sub_category.txt'...
[17:22:54]: Loading './fastlane/metadata/secondary_second_sub_category.txt'...
[17:22:54]: Loading './fastlane/metadata/review_information/first_name.txt'...
[17:22:54]: Loading './fastlane/metadata/review_information/last_name.txt'...
[17:22:54]: Loading './fastlane/metadata/review_information/phone_number.txt'...
[17:22:54]: Loading './fastlane/metadata/review_information/email_address.txt'...
[17:22:54]: Loading './fastlane/metadata/review_information/demo_user.txt'...
[17:22:54]: Loading './fastlane/metadata/review_information/demo_password.txt'...
[17:22:54]: Loading './fastlane/metadata/review_information/notes.txt'...
[17:22:54]: Verifying the upload via the html file can be disabled by either adding
[17:22:54]: `force true` to your Deliverfile or using `fastlane deliver --force`
[17:22:57]: Does the Preview on path './fastlane/Preview.html' look okay for you?
+------------------------------------+-----------------------------------------------------------------------------------------------------+
|                                                               Lane Context                                                               |
+------------------------------------+-----------------------------------------------------------------------------------------------------+
| DEFAULT_PLATFORM                   | ios                                                                                                 |
| PLATFORM_NAME                      | ios                                                                                                 |
| LANE_NAME                          | ios release                                                                                         |
| SIGH_PROFILE_TYPE                  | app-store                                                                                           |
| MATCH_PROVISIONING_PROFILE_MAPPING | "com.********.app"=>"match AppStore com.********.app"                                             |
| IPA_OUTPUT_PATH                    | /Users/********/builds/qVPSw-s1/0/********/********/client/ios/Runner.ipa                        |
| XCODEBUILD_ARCHIVE                 | /Users/********/Library/Developer/Xcode/Archives/2021-04-21/Runner 2021-04-21 17.14.18.xcarchive |
| DSYM_OUTPUT_PATH                   | /Users/********/builds/qVPSw-s1/0/********/********/client/ios/Runner.app.dSYM.zip               |
+------------------------------------+-----------------------------------------------------------------------------------------------------+
[17:22:57]: Could not retrieve response as fastlane runs in non-interactive mode
+------+--------------------------------------------------+-------------+
|                           fastlane summary                            |
+------+--------------------------------------------------+-------------+
| Step | Action                                           | Time (in s) |
+------+--------------------------------------------------+-------------+
| 1    | default_platform                                 | 0           |
| 2    | Switch to ios build_release lane                 | 0           |
| 3    | Switch to ios certificate_release lane           | 0           |
| 4    | Switch to ios get_app_store_connect_api_key lane | 0           |
| 5    | ensure_env_vars                                  | 0           |
| 6    | app_store_connect_api_key                        | 0           |
| 7    | match                                            | 2           |
| 8    | gym                                              | 522         |
| 9    | Switch to ios get_app_store_connect_api_key lane | 0           |
| 10   | ensure_env_vars                                  | 0           |
| 11   | app_store_connect_api_key                        | 0           |
| ????   | appstore                                         | 9           |
+------+--------------------------------------------------+-------------+
[17:22:57]: fastlane finished with errors
Looking for related GitHub issues on fastlane/fastlane...
➡️  Metadata Path is not considered
    https://github.com/fastlane/fastlane/issues/18321 [open] 4 ????
    2 weeks ago
➡️  GITLAB CI: Could not retrieve response as fastlane runs in non-interactive mode
    https://github.com/fastlane/fastlane/issues/17376 [closed] 18 ????
    17 Feb 2021
➡️  FastlaneCore::Interface::FastlaneCrash: [!] Could not retrieve response as fastlane runs in non-interactive mode
    https://github.com/fastlane/fastlane/issues/17488 [closed] 11 ????
    16 Jan 2021
and 53 more at: https://github.com/fastlane/fastlane/search?q=Could%20not%20retrieve%20response%20as%20fastlane%20runs%20in%20non-interactive%20mode&type=Issues&utf8=✓
????  You can ⌘ + double-click on links to open them directly in your browser.
bundler: failed to load command: fastlane (/Users/********/builds/qVPSw-s1/0/********/********/client/ios/vendor/bundle/ruby/2.6.0/bin/fastlane)
/Users/********/builds/qVPSw-s1/0/********/********/client/ios/vendor/bundle/ruby/2.6.0/gems/fastlane-2.181.0/fastlane_core/lib/fastlane_core/ui/interface.rb:129:in `crash!': [!] Could not retrieve response as fastlane runs in non-interactive mode (FastlaneCore::Interface::FastlaneCrash)

【问题讨论】:

【参考方案1】:

哪个访问拥有您的 API 密钥?尝试创建具有App Manager 访问权限的新密钥。

【讨论】:

【参考方案2】:

我能够在我的项目中通过将force: true 选项添加到我们的快速文件中的upload_to_appstore 调用来解决此问题。 Fastlane docs 列表强制作为一个选项,但它隐藏在“更多选项”下拉列表后面。

也像其他答案所说,您需要对您的 API 密钥拥有适当的权限。您需要一个具有App Manager 权限的 API 密钥来创建新的构建,这也可以让您上传 ipa。我在某处读到Developer 权限足以在App Manager 创建它之后更新构建,但我实际上并没有尝试过。

我们的快速文件中的通道现在看起来像这样:

lane :release_appstore do
  upload_to_app_store(
    ipa: "<ipa_path>.ipa",
    api_key_path: "<api_key_path>.json",
    force: true
  )
end

【讨论】:

以上是关于即使使用 API 密钥,Fastlane 上传到 App Store 也会在非交互模式下失败的主要内容,如果未能解决你的问题,请参考以下文章

Fastlane:将工件发送到外部组

使用 fastlane 上传到 S3

Fastlane 车道上传应用程序到 testflight

Fastlane- app自动编译打包多个版本上传到app store

Fastlane Deliver 说 iTunesConnect 上不存在捆绑标识符

即使我获得了 API 密钥,也无法使用谷歌地图