gpt4 book ai didi

amazon-web-services - 尝试从私有(private) Codecommit 存储库中提取时,NPM 在 CodeBuild 上安装失败

转载 作者:行者123 更新时间:2023-12-05 03:45:16 25 4
gpt4 key购买 nike

我在 codecommit 中的一个 repo 正在尝试从我的另一个 codecommit repos 中提取数据。

在第一个 repo 的 package.json 中有依赖项:

"dependencies": {
"repo-2": "git+https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/repo-2.git#TAG"
}

我的代码构建在尝试 npm install 时抛出错误(代码构建使用的是 nodejs12):

npm ERR! Command failed: git clone --mirror -q https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/repo-2.git 
/root/.npm/_cacache/tmp/git-clone-3d2bf4b6/.git
npm ERR! warning: templates not found in /tmp/pacote-git-template-tmp/git-clone-7cae5b66
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-01-26T11_58_45_260Z-debug.log

我已确保在我的策略中提供正确的权限:

      - Sid: CodeCommitRepoAccess
Effect: Allow
Action:
- codecommit:GetRepository
- codecommit:GitPull
- codecommit:GetFolder
Resource:
- arn:aws:codecommit:eu-west-1:*
- Sid: CodeCommitListRepos
Effect: Allow
Action:
- codecommit:ListRepositories
Resource: "*"

我在 buildspec.yaml 中添加了 git-credential 助手:

env:
git-credential-helper: yes

我真的不知道为什么会失败,而且错误消息没有让我知道需要修复的地方。也许我错过了政策中的一些权限? - 但由于它不是 403 错误,我不确定。我可以在我的机器上本地 npm install,没有任何问题。

编辑:实际上更清楚,我正在尝试从 repo-1 构建,它依赖于 repo-2 和 repo-3。此外,repo-2 也依赖于 repo-3。我尝试在没有嵌套私有(private)存储库的情况下运行 npm install(作为测试将其从 package.json 中删除),但构建仍然以同样的方式失败。

更新:我将行 git ls-remote -h -t https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/repo-2.git 添加到我的构建规范中,并且这会正确返回 repo-2 中的分支/标签,因此权限看起来没问题。

最佳答案

如果有人遇到同样的问题,请回答:

在安装阶段将以下内容添加到我的构建规范中解决了这个问题:

      - git config --global credential.helper '!aws codecommit credential-helper $@'
- git config --global credential.UseHttpPath true

我还需要从我的构建规范中删除 git-credential 助手:

env:
git-credential-helper: yes

我认为导致问题的原因是 npm install 在使用 env 设置时没有选择 git-credential 助手,但在明确设置时确实被选择了。

关于amazon-web-services - 尝试从私有(private) Codecommit 存储库中提取时,NPM 在 CodeBuild 上安装失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65901865/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com