Reputation: 45
I have recently installed Angular-CLI for use with Bamboo (Linux). I have verified that it works from the terminal, so I made a script task in Bamboo, which has one command: "ng build". But every time, logs show an error "ng: command not found".
What could be the source of this? The package has been installed globally, linked with NPM if that makes any difference, I have reinstalled it and verified cache, I have defined its path as an executable in Bamboo (command type, since Bamboo doesn't support Angular apparently?). I have made sure to check the command as the bamboo linux user, and it works there! But Bamboo itself doesn't see it, for some reason. Oh, and I'm using @angular/cli
, as recommended.
I'm stumped, frankly. Any help would be greatly appreciated, I've been stuck on this for a few while now.
@SSS writes...
I have added a bounty as I am having the same problem.
I am running Atlassian Bamboo v6.2.2 on Windows Server, and I get this error:
23-Apr-2020 13:49:20 + ng build --configuration=develop
23-Apr-2020 13:49:20 + ~~
23-Apr-2020 13:49:20 + CategoryInfo : ObjectNotFound: (ng:String) [], CommandNotFoundE
23-Apr-2020 13:49:20 xception
23-Apr-2020 13:49:20 + FullyQualifiedErrorId : CommandNotFoundException
My PowerShell script runs fine if I run it under my own credentials. I even added
npm install -g @angular/cli
to the script immediately before the ng build
command, but that doesn't work either.
I think it is just a case of the Bamboo agent not being able to find the ng CLI, but I can't work out where it is located.
Upvotes: 3
Views: 1771
Reputation: 3396
When the Bamboo agent starts as a service, it does not necessarily have the same PATH
variable as when you type ng
on the terminal. In particular on Windows, there was this long standing bug on the tool that started the Bamboo agent service and that has been solved in Bamboo >= 6.10.
In order to get an understanding of what is going on, just add for testing purpose a script task to your job that runs something like
echo "Printing PATH"
echo $PATH
which ng
echo "End printing PATH"
In the logs, you will certainly see that the printed PATH
is not the same as the one you have in the terminal.
Possible workarounds for this would be:
export PATH=/path/to/ng:$PATH
in each of your scriptsng
as a global executable in Bamboo and use it as a ${bamboo.capability.system.builder.ng}
variableng
in the script that starts your agent (will not work easily on Windows)Note that ng
by itself may certainly require other programs as well to be found in order to run properly.
Upvotes: 0
Reputation: 5403
I discovered a workaround by using
npm run ng build ...
inside the script, but I'd much prefer for the Angular CLI to work.
Upvotes: 0
Reputation: 846
Hmm, very strange ... Can you please post your Script configuration (like what did you chose for Interpreter (e.g. Shell) and for the script location (e.g. Inline)) ? One option of what you can do is to add an executable (Bamboo Administration\Executables) and create an executable of type command (where you have to specify the path to your command) and then you can use this executable by adding a Task of type command to your plan.
Upvotes: 0