How to automate version number in package.json with Jenkins

Here is my package.json as follows:

{ "name": "Myproject",
"version": "0.4.13",

Note : This is 4not a minor version. 0013is negligible

"dependencies": {
    "lodash": "^4.0.0",
  "vinyl-fs": "2.2.1"
},
"repository": {},
"devDependencies": {
.........
 ......

How can I automate package.json version control using the Jenkins build.

The required format should be: 0.4.13- $ BUILD_NUMBER While I try to do this with the sed command :

sed -i "s / version :. * / version: 0.4.13- $ BUILD_NUMBER /" package.json

But this is not updating the version number in the package.json file. Also used

npm version 0.4.13- $ BUILD_NUMBER

FYI: The generated assembly artifact should look like 0.0013-1.war

+4
1

grunt, .

, npm, . npm version, docs here.

+1

Source: https://habr.com/ru/post/1657567/


All Articles