Jenkins executes the shell script, prompting "command not found"

Source: Internet
Author: User
Background


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

Solution Solutions


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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.