Amplify build error "Could not read from remote repository"

0

I'm trying to setup a Vue app in Amplify Console, but getting a build error.

The app is hosted in a private Bitbucket repository and has dependencies on other private Bitbucket repsoitories (owned by same account) that are referenced in the package.json file, like so:

"foo": "git+ssh://git@bitbucket.org:example/foo.git#v1.0.0"

During the build I get the following kind of error:

error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads git@bitbucket.org:example/foo.git
Directory: /codebuild/output/src238132917/src/bar
Output:
Warning: Permanently added the RSA host key for IP address '18.205.93.2' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

After connecting Amplify to Bitbucket, I noticed an SSH key is added to the repository I connected, so I added the same key to the other repositories that are dependencies, but the build still fails.

Is it possible to make the build work?

  • Anyone know if this is still relevant? The question and answers are several years old now. Does Amplify provide any native solution for this?

asked 5 years ago3119 views
2 Answers
0

In this case, you may have to embed the access token into your clone command.
https://dotlayer.com/how-to-use-a-private-github-repo-as-a-dependency-with-yarn-npm/

answered 5 years ago
0

Based on this https://stackoverflow.com/questions/23210437/npm-install-private-github-repositories-by-dependency-in-package-json/23210615. I build this alternative to use private repos on package.json.

You can add the follow command on your amplify console build settings:

    ...
    preBuild:
      commands:
        - git config --global url."https://${GITHUB_PRIVATE_TOKEN}@github.com".insteadOf ssh://git@github.com
        - yarn
    build:
    ...

note: you need to add the GITHUB_PRIVATE_TOKEN environment variables on your Amplify Console.

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions