After upgrading to JSM Data Center 4.17.0 (which bundles Insight 9.0.7), all of our Insight automations which rely on the the Groovy HTTP Builder library (http-builder-0.7.1) to communicate with external REST APIs no longer work, severely crippling our CMDB and Incident management processes (Atlassian has removed this library in the latest version without deprecation notice).
Is there any quick way to replace groovy RESTClient calls without writing reams of HTTP handler code?
(I have raised a separate support request with Atlassian, however we need to progress while we wait for a response)
Thanks for the heads up... I'll be sure to check the impact in our environment.
Have you tried using grapes to import the library in your environment?
Add this to your insight groovy script:
@Grapes(
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
)
Thanks for the response Peter, however it appears that using grapes within Insight scripts does not work.
I've tried every imaginable combination, including manually downloading the jar file into the correct grapes location without any joy.
Insight still reports compilation errors.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using the SDK, I installed 4.17.1and 4.18.0 and was able to replicate this.
I tried to see if I could use import com.atlassian.sal.api.net.RequestFactory to generate a basic request, but I can't seem to correctly instantiate that from Insight Groovy. I have no problem in scriptrunner using the @PluginModule notation but I could not figure out how to do it natively.
I kinda got close with this:
import com.atlassian.jira.component.ComponentAccessor
def classLoader = ComponentAccessor.pluginAccessor.classLoader
Class HTTPBuilder = classLoader.loadClass('groovyx.net.http.HTTPBuilder')
Class Method = classLoader.loadClass('groovyx.net.http.Method')
Class ContentType = classLoader.loadClass('groovyx.net.http.ContentType')
classLoader.findClass('groovyx.net.http.HTTPBuilder')
System.getProperty('java.class.path')
def httpBuilder = HTTPBuilder.newInstance('http://localhost:2990')
log.info "${httpBuilder.metaClass.methods.name.sort().unique()}" //methods are correctly printed, so the class is loaded
httpBuilder.request(Method.GET){
uri.path = '/jira/status'
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I ended up writing a separate Groovy class which mimics the original RESTClient public methods (only the ones we make use of).
The implementations of these methods make use of the Apache HttpClient library which is mostly available to Insight (unfortunately, the HC fluent API is not made available to plugins).
Downside is we now have to maintain plumbing code in a script on top of the business logic, however at least we no longer face rewriting all our scripts to cater for the missing library.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.