New to Netlify but loving it so far. I would like to include the COMMIT_REF environment variable in a post processing snippet but it doesn’t seem to be working.
My snippet HTML looks like this: <script>window.commitID='{{ COMMIT_REF }}';</script>
After deployment, I see the following in my page: <script>window.commitID='';</script>
But if I replace COMMIT_REF by BRANCH, it works as expected (inserting ‘master’ into the commitID)
Not sure if it’s a bug or intended design, but there is a workaround.
Since those are all available during build, you could set a global variable on your page to hold the value (a very naive example would be a build command of echo "<script>var commitref=\"$COMMIT_REF\";" > index.html ; obviously you’ll do something more clever with process.env or let your framework help interpolate things )
Then, your snippet could refer to that variable that you’ve pre-set.