Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,411
Community Members
 
Community Events
168
Community Groups

Unable to run npm test as a task.

I'm currently trying to run 'npm test' as a task. The command is simply 'test'. When I try to run my build plan I get the following error:

 

26-Mar-2020 18:10:25> bambootest@0.1.0 test /home/bytebaron/atlassian-bamboo-7.0.2/xml-data/build-dir/BAM-BTP-JOB1
26-Mar-2020 18:10:25> react-scripts test
26-Mar-2020 18:10:25 
26-Mar-2020 18:10:25sh: 1: react-scripts: not found
26-Mar-2020 18:10:25npm ERR! Test failed.  See above for more details.

 

It appears to me like the command isn't really being run from the correct directory? I can run this command locally in a vscode terminal fine however I'm new to Bamboo and I am unsure where this command would be executed exactly. I'd appreciate any help.

1 answer

0 votes

Hi @byte_baron,

I just answered another question from you, basically on th same npm topic. There I sent a great KB on how to configure a npm task within Bamboo. Possibly, the "magic" for you is Node.js being configured correctly, so providing the path to the node and implicitly the npm binary. And also environment variable NODE_HOME to be set.

By the way, other than using Bamboo's npm task, you can also use npm's CLI and thus run your npm commands from within a Bamboo Script task. Only take care of interactive processes, like npm init, where you need to enter a bunch of data or at least hit <CR> several times. Though, npm install and npm test should work just fine.

As of your posted build log snippet, npm test fails for you because react-scripts cannot be found and likely your defined Node.js tests are in there.

So answering your question, the build log directly tells you where the build is run, namely here:

/home/bytebaron/atlassian-bamboo-7.0.2/xml-data/build-dir/BAM-BTP-JOB1

So effectively within your <Bamboo home directory> under xml-data/build-dir Bamboo creates a new folder per build and names it using PROJ-PLAN-JOB, right as you see above.

This location is called your build working directory. E.g. if you run a Source Code Checkout task, code is copied in to here. Any build operations that this plan is performing are running here. So in other words, this folder is the "core" of your build. Hence it shall provide the environment that your Bamboo build plan requires.

Find the following KB highlighting the most important Bamboo folders: Locating important directories and files.

If you want to see what resides in your plan's build working directory, you may run the following from a Bamboo Script task with Bamboo Server hosted on Linux or UNIX.

ls -al ${bamboo.build.working.directory}

Find this and many more useful Bamboo variables here: Bamboo variables.

So, summarizing, typically the Source Code Checkout task is used to make all needed files available in your plan's build working directory. Alternatively you could think about copying in what you need, from your local server or even from remote, as per simple cp or secure scp / sftp or even via rsync.

However you do that, if your data is there and accessible as it is from within your Visual Studio Code terminal, npm test should equally work from out of Bamboo.

Please check out our suggestions and let us know what more we can assist you on.

Thanks, take care and have a great weekend!
Gerhard

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events