'Jenkins, update file contents based off parameter input
I have a build that I want to update the contents of a json based on a parameter input.
I want to update: "version": "1.4.0", to whatever I put in the parameter input as releases frequently skip numbers.
I tried using execute Nodejs script, based on a guide I found. But the variable from the parameter doesn't seem to be readable.
''' const fs = require('fs');
const path = require('path');
let rawdata = fs.readFileSync(path.resolve(__dirname, '/opt/program/package.json'));
let version = JSON.parse('$version'); '''
I get a ReferenceError: $version is not defined
When I run execute shell, for example: echo '$version'
I get the output of the entered parameter.
Is there a way to update part of a json with a shell script?
Is there a better way to use execute NodeJS script?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
