Search code examples
iosapp-storefastlanefastlane-pilot

Automating Fastlane Authentication for multiple lanes


I'm trying to set up Fastfile for upload to Testflight and deliver but for no reason, I can't share my lane_context for app_store_connect_api_key. Here is my Fastfile where I'm wrong.

platform :ios do
   desc "Load ASC API Key information to use in subsequent lanes"
   lane :app_store_connect_api_key do
       app_store_connect_api_key(
       key_id: "key_id",
       issuer_id: "issuerid",
       key_content: "content",
       is_key_content_base64: true,
       duration: 500,
       in_house: false
     )
end
end
  desc "Test auth"
  lane :release do
     app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
     api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
     pilot(
     api_key: api_key,
     app_identifier: app_identifier,
     skip_submission: true,
     skip_waiting_for_build_processing: true
   )
end

When I'm trying to execute the Fastlane release I receive. Thank you! FastLane Pilot


Solution

  • You need execute app_store_connect_api_key before use API key in lane context. Like below:

    platform :ios do
       desc "Load ASC API Key information to use in subsequent lanes"
       lane :retrieve_api_key do
           app_store_connect_api_key(
           key_id: "key_id",
           issuer_id: "issuerid",
           key_content: "content",
           is_key_content_base64: true,
           duration: 500,
           in_house: false
         )
    end
    end
      desc "Test auth"
      lane :release do
         retrieve_api_key
         app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
         api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
         pilot(
         api_key: api_key,
         app_identifier: app_identifier,
         skip_submission: true,
         skip_waiting_for_build_processing: true
       )
    end