It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Flatten NPM Packages using Bamboo on Windows 2012 R2

As part of one of our builds on Bamboo, I want to flatten the npm packages using the npm package flatten-packages. To do so, I need to execute "flatten-packages" from the parent folder of the node_modules folder. Attempting to do this with a script in Bamboo fails (also fails from command prompt when remoted into build server). Attempting to do it as a Node task leaves me confused about what I should be executing, and all that I try has been to no avail in actually flattening the packages. As a Node task, I have tried running the bin/flatten file as well as lib/flatten.js, but neither work. So, the basic question is, how can I execute "flatten-packages" (which works when I do it on my own computer) as part of an automated build on a Windows 2012 R2 server? Thanks in advance.

2 answers

1 accepted

1 vote
Answer accepted

Just to share the resolution so it can help other customers, according to what we discussed on the support request you opened, you "resolved it by using the fully qualified path to the command in the script task in the Bamboo build."

Feel free to add more details here.


This might be old. But just letting others know how i made it work:

I installed flatten-packages on server globally using command: npm install -g flatten-packages

Noted down the installation path. It was: C:\Users\Administrator\AppData\Roaming\npm

Now if flatten-packages command is run from any folder on server, it would look for definition of this command in folder, if not found it would look for it in system paths.

I checked Control Panel > System > Advanced System Settings > Environment Variables > System variables > Variable value. The above installation path was not there. I added it there with semicolon separator.

Now flatten-packages command can be run from any folder on server. (So it will work from the build folder.)

I configured nodejs tasks in Bamboo UI this way:

  1. npm task with install command.
  2. Grunt task to run unit tests.
  3. JUnit parser task to parse test results.
  4. Script task to flatten packages. (Script location: inline. Script body: flatten-packages)

According to me, flatten-packages as the last task on windows server is a must have task because it lets clean-up processes delete the node_modules gracefully.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Unable to add or edit Bitbucket Cloud repository in Bamboo

On 31 May, a GDPR-related change went live in the Bitbucket Cloud API that resulted in users not being able to create or edit Bitbucket Cloud Linked repositories in Bamboo. This API update removed t...

435 views 2 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you