Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple commands in the same build step in Google Cloud Builder

I want to run our automated backend test suite on Google Cloud Builder environment. However, naturally, I bumped into the need to install various dependencies and prerequisites within the Cloud Builder so that our final test runner (php tests/run) can run.

Here's my current cloudbuild.yaml:

steps:

  - name: 'ubuntu'
    args: ['bash', './scripts/install-prerequisites.sh', '&&', 'composer install -n -q --prefer-dist', '&&', 'php init --overwrite=y', '&&', 'php tests/run']

At the moment, the chaining of multiple commands doesn't work. The only thing that's executed is the bash ./scripts/install-prerequisites.sh part. How do I get all of these commands get executed in order?

like image 792
Dzhuneyt Avatar asked Apr 26 '19 07:04

Dzhuneyt


1 Answers

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).

like image 131
guille Avatar answered Sep 30 '22 23:09

guille