如何从CodeBuild中查看CodeCommit回购?
我有一个附在CodeCommit Repo“ a”上的AWS编码器。作为构建过程的一部分,我想从repo“ a”中生成一些文物,并将其提交给CodeCommit Repo“ B”。我已经尝试包括
git clone https://git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB
在buildSpec中,但我在CodeBuild中遇到了此错误:
fatal: could not read Username for 'https://git-codecommit.us-west-2.amazonaws.com': No such device or address
[Container] 2022/04/27 22:26:42 Command did not exit successfully git clone https://git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB exit status 128
看来它没有凭据。我还尝试了在git命令中包括用户名和密码,例如git克隆https://codepipelineuser-at-- ***:***@git-codecommit.us-west-west-west-2.amazonaws.com/ v1/repos/repob
并收到此错误
[Container] 2022/04/27 21:33:45 Command did not exit successfully git clone git clone https://codepipelineuser-at-***:***@git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB exit status 129
[Container] 2022/04/27 21:33:45 Phase complete: POST_BUILD State: FAILED
[Container] 2022/04/27 21:33:45 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: git clone git clone https://codepipelineuser-at-123542344134:***@git-codecommit.us-west-2.amazonaws.com/v1/repos/AmplifySpec-Kotlin. Reason: exit status 129
:已将密码存储在参数存储中)。
如何指定CodeCommit Repo的凭据,以便在CodeBuild中查看它?
I have an AWS CodePipeline that is attached to a codecommit repo "A". As part of the build process, I want to generate some artifacts from repo "A" and commit them to codecommit repo "B". I have tried including
git clone https://git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB
in the buildspec but I get this error in CodeBuild:
fatal: could not read Username for 'https://git-codecommit.us-west-2.amazonaws.com': No such device or address
[Container] 2022/04/27 22:26:42 Command did not exit successfully git clone https://git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB exit status 128
It seems like it does not have credentials. I have also tried including the username and password in the git command like this git clone https://codepipelineuser-at-***:***@git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB
and got this error:
[Container] 2022/04/27 21:33:45 Command did not exit successfully git clone git clone https://codepipelineuser-at-***:***@git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB exit status 129
[Container] 2022/04/27 21:33:45 Phase complete: POST_BUILD State: FAILED
[Container] 2022/04/27 21:33:45 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: git clone git clone https://codepipelineuser-at-123542344134:***@git-codecommit.us-west-2.amazonaws.com/v1/repos/AmplifySpec-Kotlin. Reason: exit status 129
(I know you should never check in a password but I just did it as a test and reset the password afterwards, and the repo is empty. If that had worked I would have stored the password in Parameter Store).
How do I specify the credentials of my CodeCommit repo so I can check it out within CodeBuild?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能够通过两种方式连接到代码提交
在IAM用户上创建HTTP访问,然后使用您从访问的生成中获得的用户名/密码。
或者,您可以使用AccessKey+SecretAccesskey,但是,您需要在SecretAccesskey上使用签名V4它有点复杂
I was able to connect to code commit in 2 ways
either create HTTP access on the IAM user, and use the username/password that u get from the generation of the access.
or you can use the accessKey+secretAccessKey but, its a bit complicated you need to use Signature V4 on your secretAccessKey
您可以为您的CodeBuild项目设置IAM服务角色,该项目允许您的代码从CODECOMMIT存储库中提取代码。
这个角色可能看起来像下面,
然后您需要安装Python,PIP,AWS CLI和GIT。
AWS Linux 2023的规格文件可能包括以下内容:
它的工作原理:git配置指令
git clone
以调用aws codecommit codecommit cordecommit cordecommit cordecommit conderenter-helper
可与git-remote一起使用-codecommit
,并提供访问您存储库的git。您不需要AWS CLI配置文件,您不需要IAM用户。一切都从imdsv2撤出You can set up IAM service role for your CodeBuild project that allows your code to pull code from your CodeCommit repository.
This role may look like below
Then you need to install python, pip, aws cli and git.
spec file for AWS Linux 2023 may include the following:
How it works: git configuration instructs
git clone
to invokeaws codecommit credential-helper
that works withgit-remote-codecommit
and provides git with access to your repository. You don't need aws cli config files, you don't need IAM user. Everything is pulled out from IMDSv2