Coudebuild在PRE_BUILD阶段失败,aws cli命令无法工作

0

【以下的问题经过翻译处理】 我是AWS CodeBuild的新手,在尝试创建一个构建容器镜像的项目时遇到了困难,该容器镜像会被推送到ECR然后在Fargate上运行。

我使用了这个教程中的示例buildspec:https://docs.aws.amazon.com/codepipeline/latest/userguide/ecs-cd-pipeline.html

由于某种原因,在PRE_BUILD期间构建失败,看起来是codebuild没有识别到AWS cli命令?

以下是CloudWatch的输出:

[Container] 2022/01/22 20:03:29 Running command echo Logging in to Amazon ECR...
Logging in to Amazon ECR...
[Container] 2022/01/22 20:03:29 Running command aws --version
/codebuild/output/tmp/script.sh: 4: aws: not found
[Container] 2022/01/22 20:03:29 Command did not exit successfully aws --version exit status 127
[Container] 2022/01/22 20:03:29 Phase complete: PRE_BUILD State: FAILED
[Container] 2022/01/22 20:03:29 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: aws --version. Reason: exit status 127

我非常感谢可以得到的所有帮助,在此提前致谢!

profile picture
전문가
질문됨 6달 전36회 조회
1개 답변
0

【以下的回答经过翻译处理】 自己解决了,如果其他人也遇到了这个初学者的错误,失败的原因是我在codebuild项目中没有使用aws linux作为构建环境。我指定的镜像不支持aws cli。

profile picture
전문가
답변함 6달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인