Skip to content
← Back to activity

Immutable solution version

Access a private GitHub repository from a Cloud Build step (glide install fails)

Version 1Sign in to save

Complete solution

How to fix: Access a private GitHub repository from a Cloud Build step (glide install fails). The verified fix from the maintainer thread, distilled into reusable steps.

What happened

A Go project (A) depended on another private GitHub repository (B), and the Cloud Build pipeline could not fetch it. glide install failed with: [WARN] Unable to checkout github.com/avi/api, [ERROR] Update failed for github.com/avi/api: Unable to get repository. Cloning directly with the git builder failed too: SSH clone failed with "Host key verification failed / Could not read from remote repository", and HTTPS clone failed with "could not read Username for 'https://github.com': No such device or address". The build service account had no credentials for GitHub.

The fix that worked

Cloud Build steps have no GitHub credentials by default, so private repos are unreachable until you inject them. The recommended approach is to store a deploy key or token encrypted and pull it into the build: keep the SSH key in Cloud Storage, fetch it in an early build step, then use it for git operations (add GitHub to known_hosts to avoid the host-key verification failure). Google published a tutorial on using encrypted files in builds covering exactly this pattern. This resolved the reporter's glide/private-repo failures.

Evidence

In the thread Access a private GitHub repository from a Cloud Build step (glide install fails), the question was: A Go project (A) depended on another private GitHub repository (B), and the Cloud Build pipeline could not fetch it. glide install failed with: [WARN] Unable to checkout github.com/avi/api, [ERROR] Update failed for github.com/avi/api: Unable to get repository. Cloning directly with the git builder failed too: SSH clone failed with "Host key verification failed / Could not read from remote repository", and HTTPS clone failed with "could not read Username for 'https://github.com': No such device or address". The build service account had no credentials for GitHub. The verified resolution: Cloud Build steps have no GitHub credentials by default, so private repos are unreachable until you inject them. The recommended approach is to store a deploy key or token encrypted and pull it into the build: keep the SSH key in Cloud Storage, fetch it in an early build step, then use it for git operations (add GitHub to knownhosts to avoid the host-key verification failure). Google published a tutorial on using encrypted files in builds covering exactly this pattern. This resolved the reporter's glide/private-repo failures. Original discussion: https://vectle.com/threads/thrug35OVIWokBJ45IwGV3y8Q

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_5kACJY9SUrULtPi6jUlAtg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Access a private GitHub repository from a Cloud Build step (glide install fails) <span>— Vectle</span></a>