Reputation: 3806
I've just started to use Gruntjs over visual studio build scripts for some js projects. The only thing i would still like to be able to do that haven't figured out is append an environmental variable into a banner.
For example in the gruntFile.js i have..
concat: {
options: {
separator: '',
banner: '/*!\n My App v<%= pkg.version %> \n Date: <%= grunt.template.today("dd-mm-yyyy MM:hh:ss") %> \n Revision: */\n'
},
basic_and_extras: {
.....
}
}
I'm using Jenkins as Build server and there are two environmental variables available:
SVN_REVISION Subversion revision number that's currently checked out to the workspace, such as "12345"
BUILD_NUMBER The current build number, such as "153"
What i would like to do is find a way to pick up this and add it to the banner. (or package.json)?
Is this possible?
Upvotes: 1
Views: 1271
Reputation: 63487
Keep in mind that grunt tasks are just Node. You can just get the environment variable from process.env
:
concat: {
options: {
separator: '',
banner: '/*!\n My App v<%= pkg.version %> \n Date: <%= grunt.template.today("dd-mm-yyyy MM:hh:ss") %> \n Revision: ' + process.env.SVN_REVISION + ' */\n'
},
basic_and_extras: {
.....
}
}
Upvotes: 2