Pass variables to the next command

Hi,

This is my pipeline

steps:

- command: "cd aws && terraform init && terraform apply -auto-approve && terraform output public_dns && export URL=$$(terraform output public_dns) && echo $$URL && ssh -o StrictHostKeyChecking=no ec2-user@$$URL 'sudo docker wait pam-build'"
label: "Spin up aws environment"

Is it possible to run the commands one at the time?
Like this:

  - command: "cd aws && terraform init && terraform apply -auto-approve"
  - command: "terraform output public_dns && export URL=$$(terraform output public_dns) && echo $$URL && ssh -o StrictHostKeyChecking=no ec2-user@$$URL 'sudo docker wait pam-build'"
label: "Spin up aws environment"

Hi @zhex900!

For the pipeline you posted, I believe this might do what you want:

steps:
  - label: "Spin up aws environment"
    commands:
      - "cd paws"
      - "terraform init"
      - "terraform apply -auto-approve"
      - "terraform output public_dns"
      - "export URL=$$(terraform output public_dns)"
      - "echo $$URL"
      - "ssh -o StrictHostKeyChecking=no ec2-user@$$URL 'sudo docker wait pam-build'"

Each command is run at a time, and will stop as soon as any one fails.

You could also do it as a single text block, if that reads better:

steps:
  - label: "Spin up aws environment"
    commands: |
      cd paws
      terraform init
      terraform apply -auto-approve
      terraform output public_dns
      export URL=$$(terraform output public_dns)
      echo $$URL
      ssh -o StrictHostKeyChecking=no ec2-user@$$URL 'sudo docker wait pam-build'

We have some Command Step documentation if that helps!