Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,455,373
Community Members
 
Community Events
175
Community Groups

Insight automation crippled in JSM 4.17 (How to rewrite Groovy HTTPBuilder calls easily?)

Edited

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)

1 answer

0 votes

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.

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'
}

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.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events