Write Git commit information into a file
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-git-info --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-git-info');
This task should be configured according to the grunt Configuring tasks guide.
Parameter | Description | Default value |
---|---|---|
repository | path to git repository root | empty string |
output | name of the target file to be generated | gitInfo.json |
fields | an array defining set and order of fields of output file | branch, commit, short, timestamp, author, message, status |
{
gitInfo: {}
}
{
gitInfo: {
output: 'commit-information.json',
fields: [
'commit',
'timestamp',
'author'
]
}
}
This development was inspired by these great works:
- git-rev-2: yanatan16/git-rev
- grunt-jenkins-build-info: linuxbozo/grunt-jenkins-build-info
Licensed under terms of ISC License.
Should you have any feedback, questions, bug reports or feature requests, please file an issue.