How to use a private repository in CircleCI?

hane picture hane · Feb 7, 2018 · Viewed 8.2k times · Source

I am a tester of plugins of Redmine. I want to test all plugins.

In order to do so,I set .circleci/config.yml under one plugin's repository (managed by Github) and tried to test. But I got following mistake message.

    #!/bin/bash -eo pipefail
    git clone https://github.com/xxxxxx/lad.git
    Cloning into 'lad'...
    ERROR: Repository not found.
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    Exited with code 128

I want to find out the way of getting the clones of private repositories which are different from the repository I am using now.

The following is my .circleci/config.yml now.

version: 2

jobs:
  build:
    docker:
      - image: ruby:2.3.0
        environment:
      - LANG: C.UTF-8
    environment:
      BUNDLE_GEMFILE: /root/project/.circleci/Gemfile
    steps:
      - checkout
      - run: git clone --depth=1 --branch=${REDMINE_VERSION:-3.4-stable} https://github.com/redmine/redmine.git
      # this is private repository ↓
      - run: git clone https://github.com/xxxxxx/lad.git
      - run:
          name: Check status
          command: |
            pwd
            ls -al

Answer

FelicianoTech picture FelicianoTech · Feb 18, 2018

You'd need to add a private SSH key to CircleCI that has access to the Github repository that you are trying to clone. This would be done via the CircleCI webapp in the project's settings page. More information here: https://circleci.com/docs/2.0/gh-bb-integration/#enable-your-project-to-check-out-additional-private-repositories