Question - Assistance to get build running with TAG_NAME built-in substitutions #15
Description
I got an issue, that I have not been able to find a solution for.
I have installed and setup cloud build to be able to build code fetched from my private github repositories. It is working and I have created nice flows that builds dockers and push them to GCR
etc.
I have now added a new build where I would like to tag my docker images with the git tag
. I found that I could use the TAG_NAME
built-in substitution variable to do that. But my problem is that it is never set when running the build. It seems that when fetching/pull the code from github no tags are fetched/pull.
config yaml
substitutions:
_IMAGE_NAME: "<image_name>"
_REGION: 'europe-west1'
steps:
- name: 'gcr.io/cloud-builders/docker'
id: 'Build Docker Image'
args: ['build', '-t', "eu.gcr.io/$PROJECT_ID/${_IMAGE_NAME}:${TAG_NAME}", '--build-arg', "jarversion=${TAG_NAME}", '--build-arg', 'gitsha=${SHORT_SHA}', '.']
images:
- 'eu.gcr.io/$PROJECT_ID/${_IMAGE_NAME}:${TAG_NAME}'
Here is the tag on my git(hub) repo. (it has been pushed to remote too).
> git describe --tags $(git rev-list --tags --max-count=1)
0.0.1
So what am I missing?
This here is the build-in substitutions for latest build, found on the execution detail tab under the failed build.
Built-in substitutions
COMMIT_SHA d96122536f520eff2bd8f829625f3e873d49b3f9
SHORT_SHA d961225
BRANCH_NAME main
REPO_NAME <repo name>
REVISION_ID d96122536f520eff2bd8f829625f3e873d49b3f9
But the TAG_NAME
is not set...
Hope to hear from you soon. Thanks in advance.