title: How to Automate version number in package.json with Jenkins
body: <p>Here is my <strong>package.json</strong> looks like:</p>
  
  <p><code>{
    "name": "Myproject",</code><br>
    <code>"version": "0.4.13",</code> </p>
  
  <blockquote>
    <p><strong>Note</strong>:Here <code>4</code> is not the minor version.<code>0013</code> is minor</p>
  </blockquote>
  
  <p><code>"dependencies": {</code><br>
        <code>"lodash": "^4.0.0",</code><br>
      <code>"vinyl-fs": "2.2.1"</code><br>
    <code>},</code><br>
    <code>"repository": {},</code><br>
    <code>"devDependencies": {</code><br>
    <code>.........</code><br>
     <code>......</code></p>
  
  <p>How can I automate versioning of <strong>package.json</strong> using Jenkins build.</p>
  
  <p>Required format should be:
  <strong>0.4.13-$BUILD_NUMBER</strong>
  So far I try to do it using <strong>sed</strong> command:  </p>
  
  <blockquote>
    <p>sed -i "s/version: .*/version: 0.4.13-$BUILD_NUMBER/" package.json</p>
  </blockquote>
  
  <p>But it's not updating version number in package.json file.
  Also used </p>
  
  <blockquote>
    <p>npm version  0.4.13-$BUILD_NUMBER</p>
  </blockquote>
  
  <p><strong>FYI:The generated build artifact should look like 0.0013-1.war</strong></p>