Title, using the ng build command on Jenkins to build a angular2 project, the console outputs the following information:
/tmp/hudson3008133988036917430.sh: Line 3:ng: Command not found
Let's examine the possible causes of this problem:
Linux Host environment variable settings failed, log on to the Linux host to execute this command will still prompt "command not found"
Jenkins configuration reason, login Linux host can execute this command normally
First on the Linux host to verify, can execute normally, environment variable configuration is OK.
The Execute NG build command under Jenkins prompts "command not found", but does not have any problems with native commands such as LS. When a Linux host configures an environment variable by modifying the/etc/profile file, the problem may be that Jenkins did not load the/etc/profile file while executing the shell script, so the NG command could not be found, and the command could not be located.
Jenkins default execution of shell scripts is to use non-logon mode, but non-logon mode does not load the/etc/profile file, adding the Execute shell as the #!/bin/sh-l command to modify the login method can solve the problem.
#!/bin/sh-l
cnpm Install
ng build
rm-rfv/root/apache-tomcat-7.0.47/webapps/root/dist
mv Dist/root /apache-tomcat-7.0.47/webapps/root