Set Bazel BUILD_EMBED_LABEL to git commit SHA with state of uncommitted changes

techthumb

Kunal Parikh

Posted on January 8, 2020

Set Bazel BUILD_EMBED_LABEL to git commit SHA with state of uncommitted changes

The following git command:

git describe --always --dirty

produces this output:

a3da1ee # when working tree does not have uncommitted changed
a3da1ee-dirty # when working tree has uncommitted changed

Next, we plug the git describe command into --workspace_status_command flag

bazel build target --workspace_status_command='echo "BUILD_EMBED_LABEL `git describe --always --dirty`"'

For convenience of not having to repeat the flag, I've placed the following in .bazelrc

build --workspace_status_command='echo "BUILD_EMBED_LABEL `git describe --always --dirty`"'
πŸ’– πŸ’ͺ πŸ™… 🚩
techthumb
Kunal Parikh

Posted on January 8, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related