Jenkins - Maven错误 - 无法找到或加载主类

时间:2017-11-15 17:23:30

标签: maven jenkins selenium-webdriver cucumber-java

我第一次尝试使用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项目

1 个答案:

答案 0 :(得分:0)

似乎您看到的错误 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