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
专家
已提问 5 个月前27 查看次数
1 回答
0

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

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则