I'd like to put GO_REVISION in my ReactJs app so I can attach the commit hash to error logs. I'm using CRA which requires environment variables to be prefixed with REACT_APP_ in order to be acknowledged in the build.
My instinct is to create a GoCD environment variable named e.g. REACT_APP_GIT_COMMIT and set its value to ${env.GO_REVISION}. But when I do it through the UI, what ends up in the built file is GIT_COMMIT="${env.GO_REVISION}"
.
Is there a way to get GO_REVISION set to the commit hash into my ReactJs app?
You likely need to invoke a shell to propagate the changed environment variable name, something like
bash -c 'REACT_APP_GIT_COMMIT="$GO_REVISION" your build command here'