I am unable to build a jar in jenkins slave/master. tried different approach, however unable to resolve this below issue. The same command is helping in locally and am able to create the jar.
export PATH=/opt/apache-maven-3.6.3/bin:$PATH
mvn clean compile -f /home/iburahim/workspace/automation/ -pl testproject -am assembly:singleErrors:
10:03:29 WARNING: An illegal reflective access operation has occurred 10:03:29 WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/root/.m2/repository/org/codehaus/groovy/groovy-eclipse-batch/2.4.3-01/groovy-eclipse-batch-2.4.3-01.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int) 10:03:29 WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1 10:03:29 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations 10:03:29 WARNING: All illegal access operations will be denied in a future release 10:03:32 /home/iburahim/workspace/automation/base/src/main/groovy/com/comapny/base/config/Config.groovy: 34 Groovy:unable to resolve class Map 10:04:01 [ERROR] /home/iburahim/workspace/automation/base/src/main/groovy/com/company/base/sdk/connector/ExternalFilterConnector.java:[89,136] 9344. ERROR in /home/iburahim/workspace/automation/base/src/main/groovy/com/company/base/sdk/connector/ExternalFilterConnector.java (at line 89) 10:04:01 [ERROR] AdroitRESTDriver driver = new AdroitRESTDriver(myConfig.getConnectorByType("AdroitServer1").getConfigParam("applianceAdmin"), myConfig.getConnectorByType("AdroitServer1").getConfigParam("applianceAdminPassword")); 10:04:01 [ERROR] ^^^^^^^^^^^^^^^^^^ 10:04:01 [ERROR] The method getConnectorByType(String) from the type MyConfig refers to the missing type StringMaven, groovy3+, java installed in the slave machine (OpenSuse42). Please do help on this.
71 Answer
Finally I found an answer. Issue because of local cli and Jenkins using different java version from slave machine. When i was checking java version in Slave CLI
openjdk version "1.8.0_212" OpenJDK Runtime Environment (IcedTea 3.12.0) (build 1.8.0_212-b4 suse-34.1-x86_64) OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
When i was checking the slave machine java version through jenkins, its returning
19:09:28 + java -version 19:09:29 java version "9.0.4" 19:09:29 Java(TM) SE Runtime Environment (build 9.0.4+11) 19:09:29 Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
Then I found the mismatch and corrected in jenkins slave configuration,
Just added the java home path as /usr/lib64/jvm/jre and ran the job. jar successfully created. I hope this info helpful to someone.
1