Jenkins building a Java project can't find a command Mvn,java workaround

Source: Internet
Author: User
Tags stack trace java se

Jenkins error when building a Java project:

$ mvn clean installfatal:command execution failedjava.io.ioexception:error=2, No such file or director Yat Java.lang.UNIXProcess.forkAndExec (Native Method) at java.lang.unixprocess.<init> (unixprocess.java:247) at Java.lang.ProcessImpl.start (processimpl.java:134) at Java.lang.ProcessBuilder.start (processbuilder.java:1029) Caused:java.io.IOException:Cannot Run Program ' MVN ' (in Directory "/var/lib/jenkins/workspace/es"): error=2, No such fil E or directory



Error Case 2:

/var/lib/jenkins/tools/hudson.tasks.maven_maveninstallation/maven_3.5.3/bin/mvn clean installwhich: No Java in (/var/lib/jenkins/tools/hudson.tasks.maven_maveninstallation/maven_3.5.3/bin:/sbin:/usr/sbin:/bin:/usr /bin)The JAVA_HOME environment variable is not defined correctlythis environment variable are needed to run this progr Amnb:java_home should point to a JDK not a jrebuild step ' Invoke top-level Maven targets ' marked build as Failurefinished : FAILURE




[INFO] Changes detected-recompiling the module! [INFO] compiling source files To/var/lib/jenkins/workspace/es/target/classes[info]------------------------------------ -------------------------[ERROR] Compilation ERROR: [INFO]-------------------------------------------------------------[ERROR] No compiler is provided in this environment. Perhaps is running on a JRE rather than a JDK?[INFO] 1 Error[info]-------------------------------------------------------------[INFO]------------------------- -----------------------------------------------[INFO] BUILD Failure[info]--------------------------------------- ---------------------------------[INFO] Total time:02:42 min[info] finished At:2018-05-29t18:32:22+08:00[info]----- -------------------------------------------------------------------[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (Default-compile) on project Ruhnn-visual-search-background:compilation failure[ERROR] No compiler is provided in this environment. Perhaps is running on a JRE rather than a JDK?  [ERROR] [ERROR], [Help 1][ERROR] [ERROR]-See the full stack trace of the errors, re-run Maven with THE-E switch. [ERROR] re-run Maven using the-x switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles:< C8>[error] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException    


Workaround:

install maven and configure HTTPS in the Jenkins configuration://maven.apache.org/download.cgiwgethttp//mirror.bit.edu.cn/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gzTarZXVF apache-maven-3.5.2-bin.Tar. GZMVapache-maven-3.5.2/usr/local//usr/loca/apache-maven-3.5.2/BIN/MVN--VersionjenkinsSystem Management,Global Tools Configure MAVEN configurationSettingsfile inchFileSystem, File path/usr/local/apache-maven-3.5.2/conf/Settings.xmlglobal SettingsfileOn filesystemFile Path is pulled up and down to Maven,maven installation, Name (custom, such as Maven3.5.2), Maven_home fill "/usr/local/apache-maven-3.5.2" save" in the lower left corner

Installing MAVEN can also be consulted: http://www.cnblogs.com/weifeng1463/p/8920765.html

System Management --Global Tools Configuration JDK installation jdk  alias  JDK1. 8 automatically installs          the  Java SE Development Kit 8u162  from the java.sun.com installation version



The final test can be successfully built:



Jenkins building a Java project can't find a command Mvn,java workaround

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.