Jenkins无法通过Eclipse找到为硒项目添加的外部Jars [英] Jenkins cannot find the external Jars added for the selenium project through Eclipse

查看:113
本文介绍了Jenkins无法通过Eclipse找到为硒项目添加的外部Jars的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中有一个Maven项目.我的项目用于自动化测试.因此,在我的pom.xml中,我添加了所有依赖项.

I have a Maven project in Eclipse. My project is for Automation Testing. So in my pom.xml I've all dependencies added.

例如:Testng,Cucumber,Selenium-java等.

For example: Testng, Cucumber, Selenium-java etc..

我已经安装了Jenkins,并使用Jenkins配置了自动化项目,以便与Jenkins一起执行时,将执行该项目.

I have installed Jenkins and configured my automation project with Jenkins, so that when executed with Jenkins this project will be executed.

我已将所有依赖项添加到我的pom.xml中,因此没有任何问题.但是现在,当我在Eclipse中从外部添加jar文件时,Jenkins无法识别它,因此不会执行脚本.

I have all dependencies added to my pom.xml so no issues was there. But now when I added the jar files externally in Eclipse, it is not recognized by Jenkins and therefore, script is not executed.

这是我的测试用例:

package com.giveback360.tests.sampletest;

import org.openqa.selenium.WebDriver;
import com.giveback360.utils.OpenBrowserHelp;
import cucumber.api.java.en.When;
import org.openqa.selenium.firefox.FirefoxDriver;
import atu.testrecorder.ATUTestRecorder;
import atu.testrecorder.exceptions.ATUTestRecorderException;

public class SampleTest {

/**
* Initialize the webdriver.
*/
 private WebDriver driver = new FirefoxDriver();

/**
 * Initialize recorder.
 */
 ATUTestRecorder recorder;

 /**
 * Open browser.
 * @throws InterruptedException the InterruptedException.
 */
 @When("Open browser maximize")
  public void browserOpen() throws InterruptedException, ATUTestRecorderException {

 recorder = new ATUTestRecorder("/home/username/workspace/project/scriptVideos","TestVideo",false);
 recorder.start();

 driver.get("http://www.google.com");
 Thread.sleep(4000);
 driver.quit();

 recorder.stop();

 }

}

我在Jenkins中的控制台输出是:

My Console output in Jenkins is:

java.lang.NoClassDefFoundError: atu/testrecorder/exceptions/ATUTestRecorderException
Caused by: java.lang.ClassNotFoundException: atu.testrecorder.exceptions.ATUTestRecorderException


Results :

Failed tests: 
 SampleTest>AbstractTestNGCucumberTests.setUpClass:16 » NoClassDefFound atu/tes...

Tests run: 3, Failures: 1, Errors: 0, Skipped: 2

[ERROR] There are test failures.

问题是由于我在Eclipse中为此项目添加的ATUTestRecorder jar文件所致.

The issue is because of ATUTestRecorder jar files I've added in Eclipse for this project.

问题是如何指示Jenkins查找那些JAR文件?我应该在Jenkins中配置它还是应该怎么做?

Problem is how to instruct Jenkins to find those JAR files? Should I configure it in Jenkins or How should I do it?

任何帮助将不胜感激.预先感谢.

Any help is greatly appreciated. Thanks in advance.

推荐答案

将第三方库放入项目的lib文件夹中,然后使用<scope>system</scope>

Put 3rd party libraries in lib folder of your project.Then add them to maven with <scope>system</scope>

<dependencies>
  <dependency>
    <groupId>com.example</groupId>
    <artifactId>mylib</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/mylib.jar</systemPath>
  </dependency>
</dependencies>

这篇关于Jenkins无法通过Eclipse找到为硒项目添加的外部Jars的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆