0

I'm currently building pipeline with Google Cloud Build that has this step

steps:
  - name: 'gcr.io/cloud-builders/gcloud'
    args:
      - 'dataflow'
      - 'jobs'
      - 'cancel'
      - '$(gcloud dataflow jobs list --filter="name=iot" --status=active --limit=1 --format="value(JOB_ID)")'
      - '--region'
      - 'asia-southeast2'

The problem with this configuration is that it treats this '$(gcloud dataflow jobs list --filter="name=iot" --status=active --limit=1 --format="value(JOB_ID)")' as string instead of executing the command inside it.

So, my question is, it is possible to have $() operator in Google Cloud Build YAML file? and how?

Thanks!

fahmiduldul
  • 924
  • 7
  • 18

1 Answers1

3

You can but you have to use the bash entry point

steps:
  - name: 'gcr.io/cloud-builders/gcloud'
    entrypoint: bash
    args:
      - '-c'
      - |
          gcloud dataflow jobs cancel $(gcloud dataflow jobs list --filter="name=iot" --status=active --limit=1 --format="value(JOB_ID)") --region asia-southeast2

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76