我的一个回购是在合作中试图从另一个我的合作退出请求。
在第一个回购的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-凭据助手:
env:
git-credential-helper: yes我真的不明白为什么这是失败的,而错误信息并没有给我任何需要修复的想法。也许我在策略中漏掉了一些权限?-但由于它不是403错误,所以我不确定。我可以在我的机器上本地npm install,没有任何问题。
编辑:实际上更清楚的是,我试图从回购-1,它有一个依赖于回购-2和回购-3。此外,回购-2也依赖于回购-3。我尝试在没有嵌套私有存储库的情况下运行npm install (作为测试从package.json中删除它),但是构建仍然以同样的方式失败。
更新:我将行git ls-remote -h -t https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/repo-2.git添加到构建规范中,这正确地返回了repo-2中的分支/标记,因此权限看起来很好。
发布于 2021-01-27 15:00:48
如果有人有同样的问题,请回答:
将以下内容添加到安装阶段的buildspec解决了这个问题:
- git config --global credential.helper '!aws codecommit credential-helper $@'
- git config --global credential.UseHttpPath true我还需要从我的构建规范中删除git-凭证助手:
env:
git-credential-helper: yes我认为导致这一问题的原因是,当使用env设置git-凭据助手时,npm install并没有拾取它,而是在显式设置时被选中。
https://stackoverflow.com/questions/65901865
复制相似问题