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 prerequisi
You have 2 options to achieve this at the moment I believe:
# 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
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']
See:
By default, build steps run sequentially, but you can configure them to run concurrently.
The order of the build steps in the steps field relates to the order in which the steps are executed. Steps will run serially or concurrently based on the dependencies defined in their waitFor fields.
A step is dependent on every id in its waitFor and will not launch until each dependency has completed successfully.
So you only separate command as each step.
Like this.
steps:
- name: 'ubuntu'
args: ['bash', './scripts/install-prerequisites.sh']
id: 'bash ./scripts/install-prerequisites.sh'
- name: 'ubuntu'
args: ['composer', 'install', '-n', '-q', '--prefer-dist']
id: 'composer install -n -q --prefer-dist'
- name: 'ubuntu'
args: ['php', 'init', '--overwrite=y']
id: 'php init --overwrite=y'
- name: 'ubuntu'
args: ['php', 'tests/run']
id: 'php tests/run'
By the way, Can using ubuntu image run php and composer command?
I think that you should use or build docker image which can run php and composer command.
The composer docker image is here.
steps: - name: 'gcr.io/$PROJECT_ID/composer' args: ['install']
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).