我正在实现一个代码构建项目,但是我得到了错误的YAML_FILE_ERROR消息: batch yaml定义是必需的。到处都找过了,但一无所获。
完全错误:
[Container] 2021/07/13 17:09:46 Waiting for agent ping
[Container] 2021/07/13 17:09:49 Waiting for DOWNLOAD_SOURCE
[Container] 2021/07/13 17:09:56 Phase is DOWNLOAD_SOURCE
[Container] 2021/07/13 17:09:56 CODEBUILD_SRC_DIR=/codebuild/output/src805371762/src/git-codecommit.us-east-1.amazonaws.com/v1/repos/test_repo
[Container] 2021/07/13 17:09:56 YAML location is /codebuild/output/src805371762/src/git-codecommit.us-east-1.amazonaws.com/v1/repos/test_repo/buildspec.yaml
[Container] 2021/07/13 17:09:56 Phase complete: DOWNLOAD_SOURCE State: FAILED
[Container] 2021/07/13 17:09:56 Phase context status code: YAML_FILE_ERROR Message: batch yaml definition is required
下面是我的批处理(我甚至放入了这个“buildspec.yaml”属性,但同样的错误也发生了。
version: 0.2
batch:
fast-fail: false
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --no-include-email --region us-east-1)
build:
commands:
- echo Build started on `date`
- echo Set script permissions...
- chmod a+x docker-entrypoint.sh
- chmod a+x docker-entrypoint.d/*
- echo Building the Docker image...
- docker image build -f $DOCKER_FILE -t $IMAGE_REPO_NAME .
- docker image tag $IMAGE_REPO_NAME $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker image...
- docker image push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
- echo Writing ECSForceNewDeployment definition file...
- cat ecs-force-deploy.json > ECSForceNewDeployment.json
artifacts:
files: ECSForceNewDeployment.json
谢谢你的帮助。
发布于 2021-07-28 15:12:48
我不认为你想要批量构建设置。您的构建规范的其余部分看起来就像是“单一构建”。
batch:
fast-fail: false
发布于 2021-09-21 10:49:23
检查您的代码构建项目配置,确保它的codebuild操作设置为"build type“为"single build”,而不是"batch build“。
如果您需要它作为“批量构建”,那么您必须在buildspec中正确配置它。但我从问题中了解到事实并非如此。
要对此进行编辑,请转到您的管道-> edit -> edit stage (build) ->,然后单击AwsCodeBuild操作卡中的edit图标:
如果您使用CDK,请确保CodeBuildAction将此属性设置为false:
executeBatchBuild: false
(这是默认值,但我这样做是为了避免混淆。)
发布于 2021-09-07 01:09:05
我也遇到了同样的问题,这是因为我的“主源webhook事件”被配置为“批量构建”,而不是“单一构建”。
https://stackoverflow.com/questions/68366937
复制相似问题