Multiple commands in the same build step in Google Cloud Builder

You have 2 options to achieve this at the moment I believe:

  1. create a script that has the sequence of commands you'd like and call the script directly:
# cloudbuild.yaml
steps:
  - name: 'ubuntu'
    args: ['./my-awesome-script.sh']
# my-awesome-script.sh
/usr/bin/env/bash

set -eo pipefail

./scripts/install-prerequisites.sh
composer install -n -q --prefer-dist
php init --overwrite=y
php tests/run
  1. Call bash -c with all the commands you'd like to follow:
steps:
  - name: 'ubuntu'
    args: ['bash', '-c', './scripts/install-prerequisites.sh && composer install -n -q --prefer-dist && php init --overwrite=y && php tests/run']

A more readable way to run the script could be to use breakout syntax (source: mastering cloud build syntax)

steps:
- name: 'ubuntu'
  entrypoint: 'bash'
  args:
  - '-c'
  - |
    ./scripts/install-prerequisites.sh \
    && composer install -n -q --prefer-dist \
    && php init --overwrite=y \
    && php tests/run

However, this only works if your build step image has the appropriate deps installed (php, composer).