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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Insight + Groovy Script => Found and assign automatically the Servers? Almost the solution :-)



i already contacted Insight support about my demand, they said i need to do it by Groovy Script : 

I have an object type called "Servers". All server are automatically added using the discovery. An specific Attribute for each object called FQDN, it's simply the full name of the servers. Exemple :***.int. 

To monitore our server, we using Centreon (based on nagios), when we have a critical alert, an email is sent to mailbox Jira who create the issue. The subject of the mail is our summary. Exemple : ** PROBLEM alert - AFDAOS.f***.int/AX TEST Service is CRITICAL **.

The result expected : Assign automatically the good server depending of the summary. In this case, the system need to found the part "***.int" inside the summary and automatically assign it to this object inside a specific custom field insight. We already try (we Mindville support ) to do it using IQL but it's not working with the LIKE command.

I never use Groovy script and i don"t have any idea how to start to do it. It doesn't seem too complicated but i need help to start.
2020-06-24 12_40_37-Insight - AF Jira.png2020-06-24 12_41_34-[IT-6741] __ PROBLEM alert - AFDAOS.francois.int_AX TEST Service is CRITICAL __ .png
Thank you !

1 answer

Hello... I'm learned Groovy (as much as i can) and i'm almost the result i want ! 

Here my code :

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption


Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);

Class iqlFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
def iqlFacade = ComponentAccessor.getOSGiComponentInstanceOfType(iqlFacadeClass);

def objects = iqlFacade.findObjectsByIQLAndSchema(10,"objectTypeId = 2443");
//def test = "AF-172738"
//def ObjectInsightBean = objectFacade.loadObjectBean(test)
//log.warn("ObjectInsightBean " + ObjectInsightBean)
def n = 0
(objects).each {
CurrentObject = objects[n]
def FQDNValue = objectFacade.loadObjectAttributeBean(CurrentObject.getId(),47464).getObjectAttributeValueBeans()[0]; //Load Attribute Value
log.warn("Server " + objects[n])
//log.warn("FQDNValue " + FQDNValue)
//FQDNValueSTR = FQDNValue.ToString()
log.warn("FQDNValue " + FQDNValue)
result = (issue.getSummary().contains(FQDNValue))

log.warn("result " + result)
n ++

The output is : 

2020-06-29 16:45:28,650 [http-nio-8080-exec-17] | Server AFAW16-FS01 (AF-173140)
2020-06-29 16:45:28,650 [http-nio-8080-exec-17] | FQDNValue [2629351(]

I have the following error :

GroovyInsightException: No signature of method: java.lang.String.contains() is applicable for argument types: ( values: [[2629351(]] Possible solutions: contains(java.lang.CharSequence), contains(java.lang.CharSequence), toString(), toString(), toString(), notify()'


The problem is i want use the contain in (issue.getSummary().contains(FQDNValue)), FQDNValue have the good value but seems not be string value. It's [2629351( (what's the 2629351 value?? I just want compare the . 

Have i to import a specific plugin, use another syntax? I tried FQDNValueSTR = FQDNValue.ToString() but it's not working....

Thank you !!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍂📹 Apptoberfest demo contest roundup: vote for your favorite demos!

Hi Community! The submissions are in (and listed below) for the 🍻🍂Apptoberfest🍂🍻 Demo Competition and it’s time for you to place your votes for the best: Analytics & reporting app demo ...

286 views 7 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you