Cloud-builders: Differentiating between test, staging and prod.

Created on 23 Oct 2018  路  6Comments  路  Source: GoogleCloudPlatform/cloud-builders

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.

  1. You have a cloudbuild.yaml file in the root of a repository
  2. You have installed the Google Cloud Build, GitHub app.
  3. Builds are triggered on many different events. Not only when creating a pull request. So one could have a Cloud Build triggered for a feature branch. However, in that case you might not want all steps in the cloudbuild.yaml file executed.

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.

All 6 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

acasademont picture acasademont  路  4Comments

artjomzab picture artjomzab  路  5Comments

leighmcculloch picture leighmcculloch  路  5Comments

DocBradfordSoftware picture DocBradfordSoftware  路  7Comments

govindrai picture govindrai  路  5Comments