Jenkins 与 Maven 问题的集成



在执行 jenkins 代码时面向插件分辨率异常。当我从 eclipse 执行相同的代码时,它可以工作,但它在 jenkins 中不起作用。它向我显示插件分辨率异常。

public class LoginPageTest extends TestBase {
LoginPage loginpage;
EnquiryPage enquirypage;
HomePage homepage;
public ExcelToDataProvider dataproviderclass = new ExcelToDataProvider();
String xlfilepath = "E:\ExcelData.xlsx";
String sheetname = "Sheet1";
WaitHelper waithelper;
static Logger logger = Logger.getLogger(LoginPageTest.class);
public LoginPageTest() {
super();
}
@BeforeTest
public void setUp1() {
initialization();
loginpage = new LoginPage();
enquirypage = new EnquiryPage();
waithelper = new WaitHelper(driver);
PropertyConfigurator.configure(System.getProperty("user.dir") + "\"+XpathClass.log4jProp);
}
@Test(dataProvider = "userData", dataProviderClass = ExcelToDataProvider.class)
public void loginMethod(String username, String password) throws InterruptedException {
homepage = loginpage.login(username, password);
logger.info("login method executed");
}
@Test(dataProvider = "enquiryData", dataProviderClass = ExcelToDataProvider.class, dependsOnMethods = {"loginMethod"})
public void addEnquiry_validDetails(String name, String phNum, String emailId, String gender, String birthday, String birthMonth, String birthYr, String country, String sourceName, String institutename, String standard, String sub1, String sub2, String masterCourse, String course1, String course2, String enquiryPriority, String followuptype, String walkinDay, String walkinmonth, String walkinyr,String refferedName, String branch, String assignto,String comments )
throws Exception {
logger.info("*********************************************************************");
enquirypage.add_Enquiry();
enquirypage.stud_information(name,phNum,emailId,gender,birthday, birthMonth,birthYr, country, sourceName,institutename,standard, sub1, sub2,masterCourse,course1, course2,enquiryPriority,followuptype, walkinDay,  walkinmonth,  walkinyr, refferedName,  branch,  assignto, comments);

}
}

这是测试.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test thread-count="5" name="Test">
<classes>
<class name="testScripts.LoginPageTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->

这是我的POM.xml文件。我已经在 jenkins 中链接了这个 pom.xml 文件路径。它仍然显示错误

<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>project</groupId>
<artifactId>proctur</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>proctur</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<!-- <scope>test</scope> -->
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.inject/guice -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0-beta</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.velocity/velocity -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.uncommons/reportng -->
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.12.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<!-- <configuration> <mainClass>testScripts.LoginPageTest</mainClass> 
</configuration> -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>

<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>testScripts.LoginPageTest</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> 
<configuration> <source>1.8</source> <target>1.8</target> <fork>true</fork> 
<executable>C:Program FilesJavajdk1.8.0_212binjavac.exe</executable> 
</configuration> </plugin> -->
</plugins>
</build>
</project>

FailedConsole Output
Started by user ashwini
Running as SYSTEM
Building in workspace C:UsersProctur.jenkinsworkspaceProctur_AutomationProject
Parsing POMs
Established TCP socket on 61274
[proctur] $ "C:Program FilesJavajdk1.8.0_212/bin/java" -cp C:UsersProctur.jenkinspluginsmaven-pluginWEB-INFlibmaven35-agent-1.13.jar;C:UsersProctur.jenkinstoolshudson.tasks.Maven_MavenInstallationMavenbootplexus-classworlds-2.6.0.jar;C:UsersProctur.jenkinstoolshudson.tasks.Maven_MavenInstallationMaven/conf/logging jenkins.maven3.agent.Maven35Main C:UsersProctur.jenkinstoolshudson.tasks.Maven_MavenInstallationMaven C:UsersProctur.jenkinswarWEB-INFlibremoting-3.29.jar C:UsersProctur.jenkinspluginsmaven-pluginWEB-INFlibmaven35-interceptor-1.13.jar C:UsersProctur.jenkinspluginsmaven-pluginWEB-INFlibmaven3-interceptor-commons-1.13.jar 61274
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven:  -B -f E:New folderprocturpom.xml compile test
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------------< project:proctur >---------------------------
[INFO] Building proctur 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.20.1/maven-surefire-plugin-2.20.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.667 s
[INFO] Finished at: 2019-09-16T16:05:37+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-surefire-plugin:2.20.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-surefire-plugin:jar:2.20.1: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.20.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [Help 1]
[ERROR] 
[ERROR] To 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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
[JENKINS] Archiving E:New folderprocturpom.xml to project/proctur/0.0.1-SNAPSHOT/proctur-0.0.1-SNAPSHOT.pom
channel stopped
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/*.xml
Did not find any matching files.
Finished: FAILURE

您的特定问题可能是由各种原因引起的。

您是否在与eclipse 实例相同的计算机上运行 Jenkins?

实际错误表示为:

[错误] 插件 org.apache.maven.plugins:maven-surefire-plugin:2.20.1 或其依赖项之一无法解析: 无法读取 org.apache.maven.plugins:maven-surefire-plugin:jar:2.20.1的工件描述符:无法传输工件 org.apache.maven.plugins:maven-surefire-plugin:pom:2.20.1 从/到中央 (https://repo.maven.apache.org/maven2(: repo.maven.apache.org: 未知主机 repo.maven.apache.org -> [帮助 1]

注意:未知主机 repo.maven.apache.org

要么运行 Jenkins 的机器无法访问存储库(可能需要代理,要么主机条目不正确等(

或者你在 Jenkins本身上的代理设置不正确,开始查看你在 Jenkins 中的配置。

最新更新