Apavaiya
Apavaiya

Reputation: 87

Upload IOS build failing to testflight from fastlane on azure devops CICD pipeline

what issue am facing in Azure Console:

*"Looking for related GitHub issues on fastlane/fastlane... [!] The request could not be completed because: Authentication credentials are missing or invalid. - Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens API Key JSON created at: /Users/runner/work/_temp/appstoreconnect_api_key.json"

Below i am sharing yaml

Upload the build to TestFlight using Fastlane

  - task: Bash@3
    displayName: Upload to TestFlight using Fastlane
    inputs:
      targetType: 'inline'
      script: |
        # Set environment variables
        API_KEY_JSON_PATH=$(Agent.TempDirectory)/appstoreconnect_api_key.json

        # Upload to TestFlight using Fastlane
        fastlane pilot upload \
          --api_key_path $API_KEY_JSON_PATH \
          --app_identifier "XXXXXXXXXXXXXXX" \
          --team_id $(TEAM_ID) \
          --ipa $(build.artifactstagingdirectory)/build/*.ipa
        echo "API Key JSON created at: $API_KEY_JSON_PATH"

These two script i have shared related to issues. I checked Key_ID, ISSUER_ID, .AuthKey.p8 files, these are credencials corrects.And also set in azure portal env. Fastlane is using 2.226.

Thanks.

Upvotes: 0

Views: 38

Answers (1)

wade zhou - MSFT
wade zhou - MSFT

Reputation: 8468

It appears you are directly copying the content from AuthKey.p8 as the key value.

You need to re-encoded the content of the .p8 file to get the base64 key. please refer to the link here and here for the details(copied and pasted below).

To convert your key to base64, put it in a txt file and run one of this command below, depending on your OS. You will get a file containing the base64 string that represent your API key.

Windows: certutil -encode data.txt tmp.b64 && findstr /v /c:- tmp.b64 > data.b64 && del tmp.b64

Mac: base64 -i data.txt -o data.b64

Ubuntu: base64 data.txt > data.b64

In addition, the fastlane doc introduced official DevOps extension Apple App Store which uses fastlane. You can also use the task which support 3 different authentication methods(sample here).

Upvotes: 0

Related Questions