While setting up a my build system to automatically version my containers in Cloud Registry (How do I set an environment or substitution variable via a step in Google Cloud Build?), I ran into a frustrating error.
This works:
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker build -t gcr.io/$PROJECT_ID/$REPO_NAME:$SHORT_SHA -t gcr.io/$PROJECT_ID/$REPO_NAME:latest -t gcr.io/$PROJECT_ID/$REPO_NAME:$(cat VERSION) -t gcr.io/$PROJECT_ID/$REPO_NAME:$(cat SEMVER) -t gcr.io/$PROJECT_ID/$REPO_NAME:$(cat MAJOR) -t gcr.io/$PROJECT_ID/$REPO_NAME:$(cat MAJOR).$(cat MINOR) .']
images: ['gcr.io/$PROJECT_ID/$REPO_NAME']
But this does not work:
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker', 'build',
'-t', 'gcr.io/$PROJECT_ID/$REPO_NAME:$SHORT_SHA',
'-t', 'gcr.io/$PROJECT_ID/$REPO_NAME:latest',
'-t', 'gcr.io/$PROJECT_ID/$REPO_NAME:$(cat VERSION)',
'-t', 'gcr.io/$PROJECT_ID/$REPO_NAME:$(cat SEMVER)',
'-t', 'gcr.io/$PROJECT_ID/$REPO_NAME:$(cat MAJOR)',
'-t', 'gcr.io/$PROJECT_ID/$REPO_NAME:$(cat MAJOR).$(cat MINOR)',
'.']
images: ['gcr.io/$PROJECT_ID/$REPO_NAME']
Shouldn't these be equivalent? What am I missing?