written for work and cross posted: Cthulu and iOS CI with fastlane match and Azure Devops Pipelines

fastlane match and azure devops.markdown

Ph'nglui Mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
(In his house at R'lyeh dead Cthulh* waits dreaming.)

- Ancient scrolls from an iOS developer cult.

Fastlane is great. Fastlane Match is great. Github is great. Azure Devops build pipelines are great. Try using them all together and you'll feel like you've entered some Lovecraftian hell dimension of non-euclidian geometry and elder permissions horrors.

Here is how you fix that:

  1. Get fastlane match working locally with a Github repository USING THE SSH GIT PATH.
  2. Create a new ssh key ssh-keygen -t rsa -b 4096 -C "probably.the.shared.email.address@from.your.fastlane.setup.com"
  3. Give that key file pair a project specific name (not id_rsa).
  4. Copy the public key contents (on Mac: cat your_brand_new_project_deploy_key.pub | pbcopy) and in your certificates github repo add a new Deploy Key under settings, paste those file contents in there.
  5. In Azure Devops Pipelines, open Library. Go to secure files.
  6. Upload your brand_new_project_deploy_key and give it a sassy name.
  7. Now, add two new tasks in your build.
    1. A download secure file task, select sassy_name_deploy_key. In the Output Variables configuration section, you'll be able to set another equally sassy name to refer to this file's path in scripts, you should do that.
    2. An inline bash script task that will do this and only this: chmod 400 "$ID_PATH" where ID_PATH is set to $(your_sassy_file_location.secureFilePath) in the Environment Variables configuration for the task.
  8. Last step, I promise. In the Environment Variables configuration section for the task that is going to run fastlane match add the environment variable: GIT_SSH_COMMAND to the value: ssh -i "$(your_sassy_file_location.secureFilePath)".

Now when fastlane match runs on any build agent in your Azure Devops iOS build pool it will connect with the correct identity and sanity will be restored.

* Cthulhu, in this context, is believed to represent certificate and provisioning profile management.

Comments