I have created a bitbucket-pipelines.yml file to test a powershell script that can run on remote AWS instance.
image: python:3.5.1
pipelines:
custom:
default:
- step:
caches:
- pip
script:
- pip install awscli
- aws ssm send-command --document-name "AWS-RunRemoteScript" --instance-ids "i-xxxxx" --parameters '{"sourceType":["S3"],"sourceInfo":["{\"path\": \"https://s3.us-east-2.amazonaws.com/my-bucket-name/test.ps1\"}"],"executionTimeout":["3600"]}' --timeout-seconds 600 --region us-east-2
When i try running it, i get the following error message for the last line:
The 'script' section in your bitbucket-pipelines.yml file must be a list of strings
I checked the syntax with other online YAML validators and it shows fine. Not sure why BitBucket is having issue. Any pointers?
The second item in your list contains a colon followed by a space, which makes it a mapping in YAML.
In such cases you need to quote it. However, you already use single and double quotes and want to avoid adding more backslashes.
I prefer using block scalars for longer strings:
script:
- pip install awscli
- >-
aws ssm send-command
--document-name "AWS-RunRemoteScript"
--instance-ids "i-xxxxx"
--parameters '{"sourceType":["S3"],"sourceInfo":["{\"path\":
\"https://s3.us-east-2.amazonaws.com/my-bucket-name/test.ps1\"}"],
"executionTimeout":["3600"]}'
--timeout-seconds 600 --region us-east-2
This is a so called folded block scalar, meaning all its lines will be folded together with spaces.
May I recommend my article on quoting strings in YAML where all this is explained in detail? http://blogs.perl.org/users/tinita/2018/03/strings-in-yaml---to-quote-or-not-to-quote.html