从 Jenkins 服务器运行 maven 自动化套件时出错



我正在设置 jenkin 作业来运行我的 Maven Automation 测试套件。当我使用目标"测试"进行构建时,我得到以下错误

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building BBAPI-Automation 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ BBAPI-Automation ---
[INFO] Deleting /var/lib/jenkins/jobs/BB-APIAutomation/workspace/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ BBAPI-Automation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/lib/jenkins/jobs/BB-APIAutomation/workspace/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ BBAPI-Automation ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 18 source files to /var/lib/jenkins/jobs/BB-APIAutomation/workspace/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /var/lib/jenkins/jobs/BB-APIAutomation/workspace/src/main/java/com/bb/mapi/cities/Cities.java:[7,22] package io.restassured does not exist
[ERROR] /var/lib/jenkins/jobs/BB-APIAutomation/workspace/src/main/java/com/bb/mapi/cities/Cities.java:[8,27] package io.restassured.http does not exist

下面是我的pom.xml文件。它从 eclipse 运行,但在从 jenkin 服务器运行套件时出错。 詹金斯似乎无法下载依赖项。我不确定这个问题

<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.bigbasket</groupId>
<artifactId>BBAPI-Automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BBAPI-Automation</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${testng}</suiteXmlFile>
</suiteXmlFiles>
<printSummary>true</printSummary>
</configuration>
</plugin>
</plugins>
</build>

<properties>  
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>  
<dependencies>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>


<!-- https://mvnrepository.com/artifact/javax.mail/mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.48</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
</dependencies>
</project>  

将 io.rest-assured 添加到依赖项

<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>

最新更新