Calling java static methods from groovy dsl

609 views
Skip to first unread message

Akshay Paturkar

unread,
Apr 8, 2019, 7:04:04 AM4/8/19
to Jenkins Users
Hi All ,
I am using jenkins shared library framework , where i have requirement to publish unit test results upon completion of stage.
i have written logic for publishing result to database in java file called JenkinsUtil.java which contains different static method to push results to database.
I am importing class as import com.jda.JenkinsUtil and using it in script file pipeline.groovy as below .
I am always facing issue as 
groovy.lang.MissingPropertyException: No such property: JenkinsUtil for class

can anyone please help 

I am using this as below,

try {
stage(stageName) {
withEnv(['INSTALLER_MODULE=' + instanceName])
{
if (instanceName == 'scsc') {
sh "ant -DBUILD_MODULES='scsc' -buildfile ${BUILD_ROOT}/build/build.xml unittest_run_all create_files_for_sonaranalysis"
} else if (instanceName == 'DRM') {
withEnv(['INSTALLER_MODULE=drm'])
{
sh "ant -DBUILD_MODULES='pricing,markdown,apm' -buildfile ${BUILD_ROOT}/build/build.xml unittest_run_all"
}
} else {
sh "ant -DBUILD_MODULES='${instanceName}' -Dpatch.number='' -buildfile ${BUILD_ROOT}/build/build.xml " + target
}
}
}
println("before Jenkins Util class call")
JenkinsUtil.utStats("${BUILD_ROOT}/weblogic/utreports/dm/TESTS-TestSuites.xml", array[0], array[1], "2019.1", "${BUILD_ROOT} http://md1npdvbuild87:8080/view/Junit/job/Datamgmt-UT/Datamgmt_UT_Reports/", "")
println("after Jenkins Util class call")
}
catch (e) {
println 'exception occured at module' + instanceName + "exception occured is" + e
}





Aaron Digulla

unread,
Apr 10, 2019, 7:40:33 AM4/10/19
to Jenkins Users
This is strange. My first guess would be that the class isn't on the classpath of the script but then, the import should fail as well.

Is there a reason why you omitted the import in the code sample you pasted?

Does it work when you call it before the try{}?

Can you call other methods of the class?
Reply all
Reply to author
Forward
0 new messages