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?

gefragt vor 5 Jahren3148 Aufrufe
2 Antworten
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/

beantwortet vor 5 Jahren
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.

beantwortet vor 5 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen