I need to show the "build version" in my application. For that purpose, I am using the npm package 'git-describe', which fetches the 'distance' of the current Git commit from the last Git tag. It works fine locally where the .git folder is available along with the source code. But on the server, it does not work maybe because the '.git' folder is not part of the deployed code. Therefore, I, added a script in package.json to write the 'distance' to a file so that code can read its value later to show in the application.
I was assuming that the '.git' folder would be available for executing git commands during the CodeBuild. So, I added the above package.json script to the AWS CodeBuild pipeline. But I think I was wrong since the git command does not seem to work on the server.
Can someone please suggest how I can achieve the required functionality?