Yaml 序列条目的缩进错误bitbucket管道

Yaml 序列条目的缩进错误bitbucket管道,yaml,bitbucket-pipelines,Yaml,Bitbucket Pipelines,我目前在bitbucket管道中有一个步骤,可以做一些事情。最后一步是启动aws ecs任务,如下所示: - step: name: Migrate database script: - curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" - apt-get update - apt-get install -y

我目前在bitbucket管道中有一个步骤,可以做一些事情。最后一步是启动aws ecs任务,如下所示:

  - step:
      name: Migrate database
      script:
        - curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
        - apt-get update
        - apt-get install -y unzip python
        - unzip awscli-bundle.zip
        - ./awscli-bundle/install -b ~/bin/aws
        - export PATH=~/bin:$PATH
        - aws ecs run-task --cluster test-cluster --task-definition test-task --overrides '{ "containerOverrides": [ { "name": "test-container", "command": [ "echo", "hello world" ], "environment": [ { "name": "APP_ENV", "value": "local" } ] } ] }' --network-configuration '{ "awsvpcConfiguration": { "subnets": ["subnet-xxxxxxx"], "securityGroups": ["sg-xxxxxxx"], "assignPublicIp": "ENABLED" }}' --launch-type FARGATE
验证失败,错误如下:

序列条目的缩进错误bitbucket管道


将语句拆分为多行也不起作用。这里的正确方法是什么?

问题是冒号后跟空格,这会导致YAML解析器将其解释为映射而不是字符串

最简单的解决办法是搬家

aws ecs run-task --cluster test-cluster --task-definition test-task --overrides '{ "containerOverrides": [ { "name": "test-container", "command": [ "echo", "hello world" ], "environment": [ { "name": "APP_ENV", "value": "local" } ] } ] }' --network-configuration '{ "awsvpcConfiguration": { "subnets": ["subnet-xxxxxxx"], "securityGroups": ["sg-xxxxxxx"], "assignPublicIp": "ENABLED" }}' --launch-type FARGATE
并从管道中调用它


您还可以删除任何“:”字符后的所有空格。但是考虑到JSON的数量,在修改它时可能会再次遇到同样的问题。因此,脚本文件可能是这里比较容易的选择。

问题是您有一个冒号,后跟一个空格,这会导致YAML解析器将其解释为映射而不是字符串

最简单的解决办法是搬家

aws ecs run-task --cluster test-cluster --task-definition test-task --overrides '{ "containerOverrides": [ { "name": "test-container", "command": [ "echo", "hello world" ], "environment": [ { "name": "APP_ENV", "value": "local" } ] } ] }' --network-configuration '{ "awsvpcConfiguration": { "subnets": ["subnet-xxxxxxx"], "securityGroups": ["sg-xxxxxxx"], "assignPublicIp": "ENABLED" }}' --launch-type FARGATE
并从管道中调用它

您还可以删除任何“:”字符后的所有空格。但是考虑到JSON的数量,在修改它时可能会再次遇到同样的问题。因此,脚本文件可能是这里更简单的选项