Hi there,
I have been through the documentation up on Cloud build documentation and I'm still having a hard time identifying a way to distinguish between building for test, staging and production environment.
In the above scenario. How is it possible to "tell" Google Cloud Build to pass on certain steps in the cloudbuild.yaml file?
Furthermore, is it in some way possible to output a variable or the like that can be used by a later step in the cloudbuild.yaml file.
Thank you.
Hi,
We don't have first-class support for conditional steps, but you could use bash scripting to execute a step based on $BRANCH_NAME.
# example.yaml, probably has typos
steps:
- name: 'some-builder'
entrypoint: 'bash'
args: ['-c', 'if [ "$BRANCH_NAME" == "master" ]; then .... ']
Does this help?
Thank you that helps.
Have a good one.
The unfortunate side effect of this hack is that the container must be downloaded BEFORE the check is made. This can be redundant if the step is later decided to be not needed. This is partly the issue discussed in #138 - which is was also closed without a sound resolution.
Perhaps one these issues can be opened again until there is first class support for conditional steps?
This solution also stinks since it throws away ENTRYPOINTs in favor of bash -c :(
am curious if there were any updates on supporting better handling for conditionals?
This was a feature request. All comparable tools support this kind of pipelines, but the relevant request was closed anyway, so you cant even :+1: anymore. not a great community-friendly behaviour..
https://github.com/GoogleCloudPlatform/cloud-builders/issues/138