-2

I have the following CI/CD

build-job:
  stage: build
  script:
    - echo "Hello, $GITLAB_USER_LOGIN!"
    - ls -al
    - mkdir django_app
    - cd django_app
    - git clone git@gitlab.com:xxxxxx/yyyyyy.git .

It says

$ git clone git@gitlab.com:xxxxx/yyyyy.git .
Cloning into '.'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Cleaning up project directory and file based variables

How to clone the repository

kian
  • 1,449
  • 2
  • 13
  • 21
Santhosh
  • 9,965
  • 20
  • 103
  • 243
  • do you want to clone the same repository, or another repository? do you use an own gitlab runner? or the shared ones? - why do you want to clone the other repository, what is your motivation behind that move? – Simon Schrottner Oct 17 '21 at 12:42
  • I use shared one. Its another repository. But I have access to it. I need to build a docker image. – Santhosh Oct 17 '21 at 15:30
  • Why do you need the other repository to build a docker image? There are ways to add the host key ;) but I think the host key and the git checkout are a symptom and I would rather evaluate your root cause aka problem ;) – Simon Schrottner Oct 17 '21 at 15:36
  • Does this answer your question? [how to access multiple repositories in CI build?](https://stackoverflow.com/questions/32995578/how-to-access-multiple-repositories-in-ci-build) – irowe Apr 04 '22 at 18:26

1 Answers1

0

You need to add ssh key with access to gitlab.com:xxxxxx/yyyyyy.git to your container before you try to clone.

Daniel
  • 309
  • 1
  • 3
  • 10