1

I am trying to release the app to the app store but as 2FA is now mandatory for the apple account I am facing an issue while uploading the app to the store.

I tried using FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD as per the this link but it did not work out.

enter image description here

I have added an app-specific password in the service connection as well.

enter image description here

after adding an app-specific password in that and got the following error: also, it is saying that you can pass the password using FASTLANE_PASSWORD in the environment variable but I don't know how to pass it. enter image description here

I went through the answer provided by

Two-factor Authentication With Fastlane but it's not helping me with Azure DevOps. Is there another way to make it work?

Ragesh Pikalmunde
  • 1,333
  • 1
  • 20
  • 44

4 Answers4

3

When you download the API key, you will get a .p8 certificate (e.g AuthKey_426ZIF325NY.p8) but most probably you cannot save this file as a pipeline variable, but you can save it as a string.

Open terminal and go to your Download Folder then open your file with some Text Editor (preferred) e.g vim AuthKey_426ZIF325NY.p8 or nano AuthKey_426ZIF325NY.p8, but you can use any editor you are familiar with (e.g VS Code).

You will get something like this:.p8 certificate

You need to to save this key as string, but you cannot just copy the content, because there are some \n symbols you do not see and you will not copy them with normal copy/paste. So you need to add them manually and delete the line brakes:

Before:

-----BEGIN PRIVATE KEY-----
GTAGTAgEAMBMGByqGSM49AgEGTTqGSM49AwEHBHkwdwIBAQQg6YnlZ7oLdukc99KL
TZBVNjYeCpNQtZh3uY2SZw6jh+igCgYIKoZIzj0DAQehRANCAAQ2dMU6ss1I3760
OLjYhPBLn5f1T9ZXVbI4kFcKARM/JfPOKh7rK95LHoEOGdpBQHEaAmZo0x2pnF1+
AhD4UTiE
-----END PRIVATE KEY-----

After:

"-----BEGIN PRIVATE KEY-----\nGTAGTAgEAMBMGByqGSM49AgEGTTqGSM49AwEHBHkwdwIBAQQg6YnlZ7oLdukc99KL\nTZBVNjYeCpNQtZh3uY2SZw6jh+igCgYIKoZIzj0DAQehRANCAAQ2dMU6ss1I3760\nOLjYhPBLn5f1T9ZXVbI4kFcKARM/JfPOKh7rK95LHoEOGdpBQHEaAmZo0x2pnF1+\n
AhD4UTiE\n-----END PRIVATE KEY-----"

Now save this "After" parameter (but use your certificate) as a pipeline variable with name key. You Upload Job (Upload to TestFlight) needs access to this certificate and other two variables.

If you want, you can post your fastlane upload lane here and I will write you the additonal part.

2

How about setting all of the three variables to be environment variables?

  • FASTLANE_PASSWORD
  • FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD
  • FASTLANE_SESSION

In addition, please note that, unlike the normal pipeline variables, the secret pipeline variables will not be automatically mapped as environment variables on the agents during the pipeline running. You need to explicitly map secret variables to be environment variables. For details, see "Set secret variables".

[UPDATE]

The FASTLANE_PASSWORD should be the password of your iCloud account (or App Store Connect account). However usually it is not necessary in CI/CD pipeline.

You can try the following command line:

fastlane spaceauth -u <your-email-address>

This command line can generate a login session for your Apple ID in advance. Then you need to store the generated value inside the FASTLANE_SESSION environment variable on the agent machine.

To view more details, you can see "Storing a manually verified session using spaceauth".

Bright Ran-MSFT
  • 5,190
  • 1
  • 5
  • 12
1

Most probably the FASTLANE_SESSION is not valid anymore, so you need to create a new: https://docs.fastlane.tools/best-practices/continuous-integration/

Recommended way is to use the App Store Connect API, so you do not need 2FA and do not need to recreate fastlane session: https://docs.fastlane.tools/app-store-connect-api/

You need to set key_id, issuer_id and key once (the key can be stored as a String) and no need to change it ever.

The Account Holder must give you access to the App Store Connect API.

  • can you please tell me how and where to add that `key_id, issuer_id` and `key` in azure DevOps? – Ragesh Pikalmunde Mar 22 '21 at 06:27
  • @RageshPikalmunde Under the ApplStoreRelease task in your AzureDevOps you need to change your auth method to `App Store Connect API Key`. Once you changed that, you'll see this 3 fields show up – Tommy Leong Mar 03 '22 at 13:56
1

There are few solutions, but you can use pipeline variables for instance.

Name: key_id Value: <You will find this in AppStoreConnect>

Name: issuer_id Value: <You will find this in AppStoreConnect>

Name: key Value: <Open the .p8 Certificate in editor and add '\n' for every newline>

  • Name: `key` Value: `` I am confused about this, like where exactly this .p8 file needs to be uploaded and how to access it, can you please explain? – Ragesh Pikalmunde Apr 04 '21 at 09:51