Git tag available as environment variable at build time?

As per docs at: Build configuration · Cloudflare Pages docs
There is an env var with the commit SHA available (CF_PAGES_COMMIT_SHA).
What I’m missing is a variable carrying the git tag(s). I’d like to use it to stamp a user-readable version based on SemVer-style git tags.
Is this possible only with env vars?
For the record, I’m using Vue3 and found some Vue packages which deal with this, but I’d rather not depend on them.
It’s puzzling to me how this is not present. I guess I’m missing something, since it’s quite trivial and such an obvious feature, IMO (e.g. Gitlab’s Predefined CI/CD variables).
If it’s not, could anyone point at some CF’s wishlist/FR page to post it?


As said in Vue Docs (Modes and Environment Variables | Vue CLI), you can insert environment variables easily in your vue app using vue.config.js.

The command git tag --list will list out all the tags for you, So you just run the command and get it’s output (Execute and get the output of a shell command in node.js - Stack Overflow) and split it by new line (.split('\n')).

Then you can store it in the process.env.VUE_APP_your_variable_name variable and access in your app.

1 Like

Thanks @0ref, much appreciated.
In absence of an environment variable provided by the Cloudflare builder, I guess git as an external dependency it’s a lesser evil.
However, I’d like to have it available as an env var as it’s done for CF_PAGES_COMMIT_SHAand CF_PAGES_COMMIT_BRANCH to make things easier.
I’ve found how to post FR: there is a dedicated tag and I’ve learnt posts can be moved, so moving there.