Here is my package.json looks like:
{
"name": "Myproject",
"version": "0.4.13",
Note:Here
4
is not the minor version.0013
is minor
"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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With