Jenkins - Maven 错误 - 无法找到或加载 main class

Jenkins - Maven error - Could not find or load main class

我第一次尝试 运行 使用 Jenkins 的 maven 项目,我在 Jenkins 中收到以下错误 - 控制台 O/P.

Error: Could not find or load main class MAVEN_HOME
ERROR: Failed to launch Maven. Exit code = 1
Finished: FAILURE

我的 POM

我能够运行 eclipse 中的maven 项目成功

<i>    
        <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.aig.cucumberwork</groupId>
  <artifactId>com.aig.cucumberwork</artifactId>
  <version>0.0.1-SNAPSHOT</version>
    <dependencies>
   <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.7.1</version>
    </dependency> 
    <!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.2.2</version>
    <scope>test</scope>
</dependency>   
  </dependencies>
</project>
</i>


Maven build 
Root POM : C:\Users\marajend\test\com.aig.cucumberwork\pom.xml

我能够运行 eclipse 中的maven 项目成功

看来您看到的错误 Error: Could not find or load main class MAVEN_HOME 是清晰简洁的。您需要检查以下步骤:

  • Environment Variables 中创建一个 User Variable 作为,MAVEN_HOME 具有有效值,例如C:\apache-maven-3.3.3
  • Jenkins Configuration 中,您必须使用相同的有效值再次提及 MAVEN_HOME,例如C:\apache-maven-3.3.3