I have Cloud Build Trigger that runs on a push to a given branch of my GitHub repo.
In my cloudbuild.yaml file I am trying to access one of my private GitHub repos. That doesn’t work. Here's the step that fails:
steps:
...
- name: 'gcr.io/cloud-builders/git'
id: Clone env repository
args:
- clone
- --recurse-submodules
- git@github.com:my-username/my-service-env
The error from cloud build is:
Already have image (with digest): gcr.io/cloud-builders/git
Cloning into 'my-service-env'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
When I change the git command the error changes as well.
Different command:
steps:
...
- name: 'gcr.io/cloud-builders/git'
id: Clone env repository
args: ['clone', 'https://github.com/my-username/my-service-env.git']
New error:
Already have image (with digest): gcr.io/cloud-builders/git
Cloning into 'my-service-env'...
fatal: could not read Username for 'https://github.com': No such device or address
Looking at some docs here, it says if the build was started through a trigger you should be able to access a private repo. That doesn't seem like the case here.
I wanted to know if anyone had any success accessing their private GitHub repo this way before I start configuring SSH keys.
NB: This question is pretty much the same as this one but the answer on that page is not relevant.