AZDO: Script Task Multiline
Description:
Follow these steps to set your scripts to be multiline if you use a Windows build agent or a linux build agent. More info can be found here. Post was inspired by this and tested to confirm.
To Resolve:
- 
    As mentioned in the article in the description, the easiest fix is to just target the bashtask regardless of what your agent is. Then it will work on Windows or linux.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 - task: Bash@3 displayName: "terraform init" inputs: targetType: inline failOnStderr: true script: | terraform init -backend-config="access_key=$(my-key)" - task: Bash@3 displayName: "terraform validate" inputs: targetType: inline failOnStderr: true script: | terraform validate - task: Bash@3 displayName: "terraform plan" inputs: targetType: inline failOnStderr: true script: | set TF_LOG=ERROR set TF_LOG_PATH=$(Build.ArtifactStagingDirectory)\crash.log set terraform plan \ -var="subscription_id=$(myvar1_value)" \ -var="tenant_id=$(myvar2_value)" \ -var="client_id=$(myvar3_value)" \ -var="client_secret=$(myvar4_value)" \ -var="region=westus" \ -out "tf.plan" 
- 
    For Windows build agents specifically, use the ^character which is line continuation for batch scripts:1 2 3 4 5 6 7 8 9 - script: | terraform plan ^ -var="subscription_id=$(myvar1_value)" ^ -var="tenant_id=$(myvar2_value)" ^ -var="client_id=$(myvar3_value)" ^ -var="client_secret=$(myvar4_value)" ^ -var="region=westus" ^ -out "tf.plan" displayName: 'terraform plan' 
- 
    For linux build agents specifically, use the \character which is line continuation for bash scripts:1 2 3 4 5 6 7 8 9 10 11 12 - script: | set TF_LOG=ERROR set TF_LOG_PATH=$(Build.ArtifactStagingDirectory)\crash.log set terraform plan \ -var="subscription_id=$(myvar1_value)" \ -var="tenant_id=$(myvar2_value)" \ -var="client_id=$(myvar3_value)" \ -var="client_secret=$(myvar4_value)" \ -var="region=westus" \ -out "tf.plan" displayName: 'terraform plan' 
Comments