【问题标题】:Getting Error while running maven automation suite from Jenkins server从 Jenkins 服务器运行 Maven 自动化套件时出错
【发布时间】:2018-01-07 22:48:38
【问题描述】:

我正在设置 jenkin 作业以运行我的 Maven 自动化测试套件。当我使用目标“测试”进行构建时,我遇到了错误

[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>  

【问题讨论】:

    标签: java maven jenkins pom.xml


    【解决方案1】:

    将 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>
    

    【讨论】:

    • 你能展示你的 Cities.java 和你在那里提到的导入吗?
    • @ChandraSekhar:公共类城市扩展 CitySuiteConfig { @Test(groups = {"prod", "sanity"},priority=2) public void BBS_789_getCityList() throws IOException { RestAssured.baseURI = System. getProperty("server_url");响应 cityResponse = given()。什么时候()。获取(CitiesResourceClass.cityResource())。 then().assertThat().statusCode(200).and().contentType(ContentType.JSON)。提取()。响应(); System.out.println(cityResponse.asString()); Reports.reporter("城市列表", true); } }
    • 在编译执行代码的时候有没有手动检查过jar rest-assured是否被下载??
    • 对不起,jenkins,jar 文件没有下载
    • @ChandraSekhar:有什么线索吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 2012-08-18
    • 2020-12-18
    • 2014-10-31
    • 2013-02-08
    相关资源
    最近更新 更多