Accessing private dependencies and Git submodules

If your project requires accessing any private Git submodules or dependencies, you’ll need to grant Codemagic access to them in order to build successfully.

  1. Create an SSH key pair for use with Codemagic. Note that the SSH key cannot be password-protected.

  2. Add the public key to your repository settings. See how to do that on GitHub, Bitbucket, GitLab.

  3. Encrypt the contents of the private key file and add it as an environment variable in your Codemagic configuration configuration file. . (../building/environment-variables/). Make sure to check Secure. For example:


All environment variables whose name has the suffix _SSH_KEY will be automatically added to the SSH agent and will be ready for use during the whole build process. Check the Preparing build machine step in build logs to verify that the key has been successfully added to the SSH agent.

If you wish to use a custom environment variable name without the suffix _SSH_KEY, add the following post-clone script to add the key to the SSH agent.

#!/usr/bin/env sh
echo "${CUSTOM_KEY_NAME}" > /tmp/ssh_key
chmod 600 /tmp/ssh_key
eval `ssh-agent -s`
ssh-add /tmp/ssh_key