The environment variable CACHED_COMMIT_REF
is now available to your builds. It contains the reference ID (also known as ‘SHA’ or ‘hash’) of the last commit that Netlify built before the current build.
See the Netlify docs about environment variables for more information on this and other environment variables you can use to customize your builds.