Issue
Here is my package.json looks like:
{
"name": "Myproject",
"version": "0.4.13",
"dependencies": {
"lodash": "^4.0.0",
"vinyl-fs": "2.2.1"
},
"repository": {},
"devDependencies": {
.........
......
How can I automate versioning of package.json using Jenkins build.
Required format should be: 0.4.13-$BUILD_NUMBER So far I try to do it using sed command:
sed -i "s/version: .*/version: 0.4.13-$BUILD_NUMBER/" package.json
But it's not updating version number in package.json file. Also used
npm version 0.4.13-$BUILD_NUMBER
FYI:The generated build artifact should look like 0.0013-1.war
Solution
If you're using grunt, you could use the recommendation here.
Alternatively, there's a built in function in npm that does this for you. Run npm version
, docs here.
Answered By - Dandy Answer Checked By - David Marino (WPSolving Volunteer)