通过Jenkins中的run.bat文件运行git测试时,在类路径异常中找不到类

时间:2018-12-18 11:47:52

标签: selenium testing jenkins github selenium-webdriver

我正在学习使用Jenkins通过Git执行蚀自动化代码。手动运行bat脚本时,它可以正常运行。但是,通过Git运行它时,它会抛出Classpath异常中找不到的类。

错误日志

Building in workspace C:\Users\DELL\.jenkins\workspace\JenkinsGitTest
 > git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git.exe config remote.origin.url https://github.com/Satish152/GitTest.git # timeout=10
Fetching upstream changes from https://github.com/Satish152/GitTest.git
 > git.exe --version # timeout=10
 > git.exe fetch --tags --progress https://github.com/Satish152/GitTest.git +refs/heads/*:refs/remotes/origin/*
 > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 2e7f307474859cf6d5a4323cf210fbdd8a63200b (refs/remotes/origin/master)
 > git.exe config core.sparsecheckout # timeout=10
 > git.exe checkout -f 2e7f307474859cf6d5a4323cf210fbdd8a63200b
Commit message: "changes made in class name"
 > git.exe rev-list --no-walk fd6a75f2c57c49a45971fe35ec8b047910849b16 # timeout=10
[JenkinsGitTest] $ cmd /c call C:\Users\DELL\AppData\Local\Temp\jenkins1401414693910390241.bat

C:\Users\DELL\.jenkins\workspace\JenkinsGitTest>run.bat

C:\Users\DELL\.jenkins\workspace\JenkinsGitTest>set classpath=H:\workspace\GitHubTest\bin;H:\workspace\GitHubTest\lib\*; 

C:\Users\DELL\.jenkins\workspace\JenkinsGitTest>java -cp bin;lib\* org.testng.TestNG testng.xml 
[TestNG] [ERROR] 
Cannot find class in classpath: gitTest.DemoGitTest
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

我在下面添加了Jenkins项目配置屏幕截图:

Git project configuration in [![Git project configuration in jenkins1詹金斯] 2] 2

1 个答案:

答案 0 :(得分:2)

可能是您覆盖了classpath并且缺少分号;,请尝试

set classpath=H:\workspace\GitHubTest\bin;H:\workspace\GitHubTest\lib\*; 
java org.testng.TestNG testng.xml

或删除set classpath并执行

java -cp bin/*;lib/*; org.testng.TestNG testng.xml