Groovy Scripting of Jazz API pauses after executing
We have implemented a way to run Jazz API methods through groovy using the hints shown at this link: https://jazz.net/forum/questions/150675/how-can-i-script-jazzrtc-using-groovy
So the groovy scripts do exactly what they're supposed to - we have scripts to do things like change build label, set RTC work item actions, add attachments, etc. However, there's a really big problem that comes with the groovy scripting - after the script finishes, the execution pauses for anywhere from 30 to 90 seconds after execution completes. We've verified this by putting trace printlns at the beginning and end of the script. We have a calling script and an "RTC" master class where all the methods that operate directly on RTC are located.
For instance, one calling script:
import com.ibm.team.repository.client.TeamPlatform
import das.*
def REPO_URL = System.getenv("RTC_REPO_URL") ?: "https://rtcccm.bcbst.com/ccm"
def USER_ID = args[0]
def PASSWORD = args[1]
def RESULTUUID = args[2]
def LABELVALUE = args[3]
def LINKVALUE = args[4]
def p(obj) {
println "${obj}"
}
println "Start"
TeamPlatform.startup()
def rtc = new RTC(REPO_URL, USER_ID, PASSWORD)
rtc.login()
rtc.addBuildResultLink(RESULTUUID, LABELVALUE, LINKVALUE)
rtc.logout()
TeamPlatform.shutdown()
println "Stop"
Will show "Start" and "Stop" rather quickly, but the script won't actually complete for a noticeable amount of time.
Could anyone fill me in on why this extended pause happens after API execution, and if there's any way to resolve it?
Accepted answer
I have no idea about using Groovy...... But the Wiki refers to the build system toolkit as the container for the plain java client libraries. Do you use the build system toolkit? This bundle might have some differences to the other packaging of the plain java client libraries.
I am not sure if this is relevant, but I have written an application that uses the TeamPlatform but can be run as a RMI server (to avoid repeatedly have to login which cost up to 8 seconds). I had to explicitly add some code to shut down the team platform, otherwise the whole thing would hang and never terminate. The team platform would keep the Java VM/runtime alive. What you describe kind of smells like something like that.
The code I had to use was:
/** * Hook to terminate gracefully * */ private static class TerminateRuntimeHook extends Thread { @Override public void run() { if (TeamPlatform.isStarted()) { // System.out.println("Shutting down Team Platform ..."); TeamPlatform.shutdown(); } } } // Add the hook private static final TerminateRuntimeHook hook; static { hook = new TerminateRuntimeHook(); Runtime.getRuntime().addShutdownHook(hook); }