Search code examples
google-cloud-platformterraformgoogle-cloud-buildterraform-provider-gcp

Using bash variables in arguments in Google Cloud Build provider


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:


Solution

  • 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)} ."]         
        }