Using bash variables in arguments in Google Cloud Build provider

671 views Asked by At

Here is one of my steps in the cloud build trigger.

step {
      name = "gcr.io/cloud-builders/docker"       
entrypoint = "bash"
      args = ["-c", "docker", "build", "-t", "gcr.io/something:$(date +%m.%d)", "."]          
    }

It applies properly, but when I try to run the trigger, it complains about having a bad tag name. failed to find one or more images after execution of build steps:

1

There are 1 answers

1
21rw On BEST ANSWER

The arguments shouldn't be separated. It should look like:

step {
      name = "gcr.io/cloud-builders/docker"       
entrypoint = "bash"
      args = ["-c", "docker build -t gcr.io/something:$(date +%m.%d)} ."]         
    }