I have setup a test pipeline and deployment pipeline.
During deployment I'd like to get package.json version and put the value in a new variable.
I have found some ways that work in bash like:
first creation a version script in package.json that return the version:
"version": "echo $npm_package_version"
Then assigning the result to a variable.
$VERSION=$(npm run version --silent)
Is there a way to do this in the pipeline?
When trying I get an error :
+ $VERSION=$(npm run version --silent)
bash: =1.0.6: command not found
It retrieves the version number but still throws an error ?
any suggestions are welcome
Hi Yassine,
You can create a version script as you mentioned in your package.json
"scripts": {
"version": "echo $npm_package_version"
}
and then you can add to your bitbucket-pipelines.yml
VERSION=$(npm run version --silent)
The example you provided does not work because of the $ in front of VERSION.
Hope this helps!
@davina Thank you for your answer. I had indeed made a syntax mistake there.
The solution now works perfectly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can someone help, please. The "npm run" is not working in my pipeline. Here is the line of code:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unlock your potential and learn how to use Jira Product Discovery to your advantage. You’ll have the expertise to revolutionize ideas and insights, roadmapping, engage and align teams and stakeholders, and deliver the best solutions—faster. Enroll today!
Start Learning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.