Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

how can I access the package.json version while running pipeline

Yassine Jouahri March 20, 2018

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

1 answer

1 accepted

5 votes
Answer accepted
davina
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 27, 2018

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!

Yassine Jouahri March 27, 2018

@davina Thank you for your answer. I had indeed made a syntax mistake there.

The solution now works perfectly.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events