我正在尝试从GitHub中存储的Jenkins执行Maven项目,并收到以下错误消息
当我在本地(Eclipse)中执行相同操作时,没问题。
在“全局”配置中设置正确的JDK路径。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project SeleniumMaven_Git_Jenkins: Compilation failure: Compilation failure:
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[9,17] error: package org.testng does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[10,17] error: package org.testng does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[11,17] error: package org.testng does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[12,17] error: package org.testng does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[13,17] error: package org.testng does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[14,17] error: package org.testng does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[15,21] error: package org.testng.xml does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[21,41] error: cannot find symbol
[ERROR] symbol: class IReporter
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[24,33] error: cannot find symbol
[ERROR] symbol: class XmlSuite
[ERROR] location: class ExtentReporterNG
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[24,59] error: cannot find symbol
[ERROR] symbol: class ISuite
[ERROR] location: class ExtentReporterNG
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\ExtentReportListener\ExtentReporterNG.java:[45,29] error: cannot find symbol
[ERROR] symbol: class IResultMap
[ERROR] location: class ExtentReporterNG
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\retryanalyzer\RetryTransform.java:[6,17] error: package org.testng does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\retryanalyzer\RetryTransform.java:[7,29] error: package org.testng.annotations does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\retryanalyzer\RetryTransform.java:[9,39] error: cannot find symbol
[ERROR] symbol: class IAnnotationTransformer
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\retryanalyzer\RetryTransform.java:[11,23] error: cannot find symbol
[ERROR] symbol: class ITestAnnotation
[ERROR] location: class RetryTransform
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\retryanalyzer\RetryAnalyzer.java:[3,17] error: package org.testng does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\retryanalyzer\RetryAnalyzer.java:[4,17] error: package org.testng does not exist
[ERROR] C:\Users\ADMIN\git\MavenDemoProject\SeleniumMaven_Git_Jenkins\src\main\java\com\qa\easy\retryanalyzer\RetryAnalyzer.java:[6,38] error: cannot find symbol
[ERROR] symbol: class IRetryAnalyzer
答案 0 :(得分:1)
从pom文件的testng依赖中注释掉或删除<scope>test</scope>
。
保存pom文件,然后进行编译,应该可以。
答案 1 :(得分:0)
清除.m2 /存储库中的数据,然后尝试。
答案 2 :(得分:0)
两件事
POM.xml
,如果Jenkins在具有代理的服务器上运行,则必须对其进行配置。.m2/repository
清除缓存。如果这不起作用,请分享您的POM.xml
答案 3 :(得分:0)
根据pom.xml中的代码,删除scope标记。它将起作用