Reputation: 381
I have a maven project set up in Jenkins. I have made an update to the code, committed and pushed it to remote(Git Repository). I configure the jenkins with maven goal as test and click the build now, Then I get errors when compiling the classes in Jenkins. As Per I Know Maven only took those classes to test that are present under src/test/java path. When I Was building the project through Jenkins, I got the below Compilation Error,
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ myTestMaven ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\s\.jenkins\workspace\meven_jenkin_sele\myTestMaven\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/s/.jenkins/workspace/meven_jenkin_sele/myTestMaven/src/main/java/com/testingMeven/myTestMaven/App.java:[3,30] package org.testng.annotations does not exist
[ERROR] /C:/Users/s/.jenkins/workspace/meven_jenkin_sele/myTestMaven/src/main/java/com/testingMeven/myTestMaven/App.java:[16,6] cannot find symbol
symbol: class Test
location: class com.testingMeven.myTestMaven.App
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
My git Repo link https://github.com/SACTAN/myTestMaven
I Tried adding annotation for App.java but still same error got. When I Run the same code on my Local its working fine but not working through Jenkins. Any ideas what could be going wrong ?
Upvotes: 0
Views: 799
Reputation: 31234
You cannot use dependencies with scope test
in src/main
. If you want to use TestNG in your main code then you can remove <scope>test</scope>
from the TestNG dependency
in your POM.
This goes for any Maven dependency and not just TestNG. Read Dependency Scope to learn more.
Upvotes: 1