0
  post_build:
    commands:
      - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
      - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
      - cat <<'EOF' > appspec.json
        {
           "\"version\"":0.0,
           "\"Resources\"":[{
             "\"TargetService\"":{
               "\"Type\"":"\"AWS::ECS::Service\"",
               "\"Properties\"":{
                 "\"TaskDefinition\"":"\"arn:aws:ecs:ap-southeast-1:414193698200:task-definition/deploy-wmi:1\""
               }
             }
           }]
        }
        EOF

嗨,如何在 codebuild buildspec 中创建 appspec.json 构建工件?我在上面试过了,它不起作用。错误是:

    /codebuild/output/tmp/script.sh: line 8: warning: here-document at line 4 delimited by end-of-file (wanted `EOF')
cat: {: No such file or directory
cat: "version":0.0,: No such file or directory
cat: "Resources":[{: No such file or directory
cat: "TargetService":{: No such file or directory
cat: "Type":"AWS::ECS::Service",: No such file or directory
cat: "Properties":{: No such file or directory
cat: "TaskDefinition":"arn:aws:ecs:ap-southeast-1:414193698200:task-definition/deploy-wmi:1": No such file or directory
cat: }: No such file or directory
cat: }: No such file or directory
cat: }]: No such file or directory
cat: }: No such file or directory
cat: EOF: No such file or directory

我也尝试在 EOF 之前添加 { 的前面,但它也不起作用:

    /codebuild/output/tmp/script.sh: line 8: warning: here-document at line 4 delimited by end-of-file (wanted `EOF')
cat: {: No such file or directory
cat: "version":0.0,: No such file or directory
cat: "Resources":[{: No such file or directory
cat: "TargetService":{: No such file or directory
cat: "Type":"AWS::ECS::Service",: No such file or directory
cat: "Properties":{: No such file or directory
cat: "TaskDefinition":"arn:aws:ecs:ap-southeast-1:414193698200:task-definition/deploy-wmi:1": No such file or directory
cat: }: No such file or directory
cat: }: No such file or directory
cat: }]: No such file or directory
cat: }: No such file or directory
cat: EOF: No such file or directory

我也尝试将所有内容放在一行中 ({"version":0.0,...) 但我的 CodeDeploy 说模板无法解析。谢谢

4

0 回答 0