- NPM Downloads Last Month
This plugin creates an operating system file containing the current git commit version. It also has the ability to update an existing file with the current git commit version.
npm install serverless-git-commit-tracker --save-dev
plugins: - serverless-git-commit-tracker custom: gitCommitTracker: location: ./version.txt
location key tells Git Commit Tracker where it should write the file.
Now, when you deploy your project a new file will be created with the current git commit version. Note: This file is created after you commit to git so the newly created file will not be part of the referenced git commit.
custom: gitCommitTracker: location: ./version.txt deployment: - dev - production - qa
deployment directive the version file is created for every deployment. With the
deployment directive the version file is created only for deployments matching the list following the directive. For example,
sls deploy --stage production will result in the version file being created. However,
sls deploy --stage test will NOT create the version file.
custom: deploymentTracker: location: ./version.txt deployment: - dev - production - qa html: true
The default behavior is to create a text file with line feeds. However, the
html directive replaces the line feeds with html
custom: deploymentTracker: location: ./version.txt deployment: - dev - production - qa html: true regex: '(<span>).*(<\/span>)'
regex directive allows you to replace a stub in an existing file. This is useful if you have an HTML file and you want to only update a given section with the version information. The regex expression uses backreferences to keep the beginning and ending markers in the file for replacement next time. Therefore, the regex expression must contain parentheses around both the beginning and ending markers. In the above example, the
<span> elements will be used as the markers.
It is also possible to create the version file using a command:
sls gitTrackerCreate will create the same file as deployment would have created.
sls getCommitVersion will return the current git commit version on the command line