Docker Community Forums

Share and learn in the Docker community.

Reference git commit hash in the docker hub automated build Docker Tag field

Is it possible to reference a subset of the characters in the git commit hash in the Docker Tag of the docker hub automated build process (referring to the page at https://hub.docker.com/repository/docker/$USERNAME/$REPOSITORY_NAME/builds/edit)? I have been manually tagging images for a container I maintain with, for example 0.1-1d50ea4 where 1d50ea4 derives from the first seven characters of the git commit hash from which the container image was built.

I reviewed the documentation on docker hub automated builds but was not able to find a complete listing of the variables available in the “Docker Tag” field in the “Build Rules” section of the “Build configurations” page for my repository. The examples include {sourceref}, which appears to refer to the git tag but I am wondering if there is a {commitref} or something of that nature.

If all of the environment variables listed on the Advanced options for Autobuild and Autotest#environment-variables-for-building-and-testing were available in the docker hub Docker Tag field then perhaps something to do with {SOURCE_COMMIT} would work, if there were a way to select a subset of that string there. However, I don’t know if those environment variables are available in that context, and if so, how to manipulate them.