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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南