CircleCI run multi line command

From here:

     steps:
       - run: |
           s3cmd --access_key ${<< parameters.access-key >>} \\
                 --secret_key ${<< parameters.secret-key >>} \\
                 << parameters.command >>

This is an old one, but it's had a lot of views so what I've found seems worth sharing.

In the CircleCI docs (https://circleci.com/docs/2.0/configuration-reference/#shorthand-syntax) they indicate that in using the run shorthand syntax you can also do multi-line.

That would look like the following

- run: |
    git add --all
    git commit -am "a commit message"
    git push

The difference between the question's example and this is the commands are under "run", not "command".


You'll need to pass those other commands as args to a shell (like bash):

ssh -o StrictHostKeyChecking=no [email protected] bash -c '
      cd ~/circleci-aws
      git pull
      npm i
      npm run build
      pm2 restart build/server'