yamlbitbucket-pipelines

Bad indentation of a sequence entry bitbucket pipelines


I currently have a step in bitbucket pipelines which does some stuff. The last step is to start an aws ecs task, like this:

  - 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

This fails the validation with the error:

Bad indentation of a sequence entry bitbucket pipelines

Splitting the statement up on multiple lines is not working either. What would be the correct approach here?


Solution

  • The issue is you have a colon followed by a space, which causes the YAML parser to interpret this as a map and not a string.

    The easiest solution would be to move

    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
    

    Into a script file, and call it from Pipelines.

    You could also remove all the spaces after any ':' characters. But given the amount of JSON there, you'd likely encounter the same issue again when modifying it. So the script file is probably the easier option here.