Flatten NPM Packages using Bamboo on Windows 2012 R2

Scott Hoelsema June 3, 2015

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
Felipevsw
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 5, 2015

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.

Cheers!
Felipe

0 votes
Roshan Fernandes October 5, 2016

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
TAGS
AUG Leaders

Atlassian Community Events