Run bash commands within steps/command: instead of running script.sh

Question about command:
Is it possible to execute whole bash script from steps/command: instead of wrapping it up into a script.sh and executing as a script? (command: script.sh)
e.g.

- label: ":yaml: RUN SCRIPT"
  command: | 
     "A=2"
     "B=3"
      if [[ $A == $B ]] ; then 
               echo "well done"
    - else 
             echo "nope"
    - fi

Reason for asking is that I would like to control few things from buildkite level instead of first pushing scripts to the repo etc

@novak100

Absolutely! The example you provided is pretty much exactly how you would do that. The only thing you would need to change is to fix up the syntax in your block:

  - label: ":yaml: RUN SCRIPT"
    command: |
      A=2
      B=3
      if [[ \$A == \$B ]] ; then
        echo "well done"
      else
        echo "nope"
      fi

Hope that helps!

I always make sure I explicitly set -e on those in-line scripts to make sure they error if a single command fails:

command: |
  #!/bin/bash -e
  A=2
  B=3
  if [[ \$A == \$B ]] ; then
    echo "well done"
  else
    echo "nope"
  fi

Thanks, @moensch for the info!

I just ran a test with some failing steps and without the -e set. When it reached the failing step, it immediately stopped the command step and exited. So I think -e is not necessary as the script is part of the command step which by nature exits when there is a failure.

Please let us know if you see different behavior.