我没有看到解决我的问题的答案,所以在这里。我有一个简单的maven项目用于执行testNG自动化测试。当我通过命令行在项目的根目录中使用mvn clean install
构建包时,所有内容都可以正常运行并运行测试。
但是,当我从jenkins运行此构建时,构建将失败并显示Error: Could not find or load main class jenkins.maven3.agent.Maven32Main
。似乎詹金斯无法读取奴隶基础文件夹中的罐子。以下是详细信息:
Jenkins日志:
[EnvInject] - Loading node environment variables.
Building remotely on AUTOMATION-DEV (test) in workspace workspace/PreSale API
Fetching changes from the remote Git repository
Fetching upstream changes from git://github.ove.local/QA/ODS.git
Checking out Revision ad9aedb4b1bee8804d95c663c01bf1d696d711a6 (origin/ods_presales_api)
Parsing POMs
Copied maven32-agent.jar
Copied maven32-interceptor.jar
Copied maven3-interceptor-commons.jar
[ODSPreSalesApi] $ java -Xmx512m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -cp maven32-agent.jar;C:\apache-maven-3.3.3\boot\plexus-classworlds-2.5.2.jar;C:\apache-maven-3.3.3/conf/logging jenkins.maven3.agent.Maven32Main C:\apache-maven-3.3.3
C:\jenkins\launcher\slave.jar maven32-interceptor.jar maven3-interceptor-commons.jar 57700
Error: Could not find or load main class jenkins.maven3.agent.Maven32Main
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:"C:\Program Files (x86)\HP\Unified Functional Testing\bin\java_shared\classes";"C:\Program Files (x86)\HP\Unified Functional Testing\bin\java_shared\classes\jasmine.jar"
ERROR: Failed to launch Maven. Exit code = 1
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/testng-results.xml
testng-results.xml was last modified before this build started. Ignoring it.
Saving reports...
Found matching files but did not find any TestNG results.
Finished: FAILURE
路径(与问题相关):
%M2_HOME%\bin;%JAVA_HOME%\bin;C:\jenkins\launcher;C:\Program Files (x86)\Git\cmd
JAVA_HOME:
C:\Program Files (x86)\Java\jdk1.7.0_79
M2_HOME:
C:\apache-maven-3.3.3
M2:
C:\apache-maven-3.3.3\bin
我是詹金斯的maven配置的新手,所以我假设我错过了一些简单的东西。
PS - 我已经为windows slave创建了特殊的Jenkins配置,指向maven到C:\apache-maven-3.3.3
和java主目录。这些是在构建作业上配置的。