Checkout private repositories with local jobs run through circleci cli

Overview

One of the several uses of the CircleCI CLI is to run jobs locally. However, it is currently not possible to add SSH keys using the add_ssh_keys CLI command.

Essentially, in this case, you'll need to pass some form of credentials into the container.

Basic authentication

You can set your VCS username/password as environment variables and pass them to the CLI with the -e flag, for each variable. This would allow you to clone the repository with basic authentication.

SSH key

Alternatively, you can base64-encode the private key and pass it into the job as an environment variable as well.
Then you can decode it into a file within a run command in your custom local config.
Once decoded into a file you can use ssh-add -K path/to/key. This would allow you access to the remote repository through SSH key based authentication.

Was this article helpful?
2 out of 21 found this helpful

Comments

0 comments

Article is closed for comments.