YAML_FILE_ERROR 消息:需要批处理 yaml 定义

问题描述 投票:0回答:5

我正在实现一个代码构建项目,但收到错误 YAML_FILE_ERROR 消息:需要批处理 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 (我什至放置了这个“batch”属性,但发生了同样的错误。

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

感谢大家的帮助。

amazon-web-services aws-codebuild
5个回答
3
投票

检查您的 codebuild 项目配置并确保其 CodeBuild 操作将“构建类型”设置为“单一构建”而不是“批量构建”。

如果您需要将其作为“批量构建”,那么您必须在构建规范中正确配置它。但我从问题中了解到事实并非如此。

要编辑此内容,请转到管道 -> 编辑 -> 编辑阶段(构建)->,然后单击 AwsCodeBuild 操作卡中的编辑图标:

option screen capture

如果您使用 CDK,请确保 CodeBuildAction 将此属性设置为 false:

executeBatchBuild:假

(这是默认值,但我这样设置是为了避免混淆。)


1
投票

我认为您不需要批量构建设置。您的构建规范的其余部分看起来像“单一构建”。

batch:
  fast-fail: false

1
投票

我遇到了同样的问题,这是由于我的“主源 webhook 事件”被配置为执行“批量构建”而不是“单个构建”导致的


0
投票

如果没有 pipeline ,请使用

Start build with overrides
启动构建,而不是默认的启动构建。

Start build with overrides
后,您必须选择从
Single build
 改回 
Batch Build


0
投票

这次我遇到了同样的错误,伙计们。 下载源 失败的 YAML_FILE_ERROR:需要批量 yaml 定义。

请问有什么解决办法吗

© www.soinside.com 2019 - 2024. All rights reserved.