Hello,
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 : AFDAOS.fr***.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 "AFDAOS.fr***.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.
Thank you !
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.riadalabs.jira.plugins.insight.services.model.CommentBean;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.services.model.ObjectAttributeBean
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);Class iqlFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade");
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(AFAW16-FS01.francois.int)]
I have the following error :
GroovyInsightException: No signature of method: java.lang.String.contains() is applicable for argument types: (com.riadalabs.jira.plugins.insight.services.model.ObjectAttributeValueBean) values: [[2629351(AFAW16-FS01.francois.int)]] 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(AFAW16-FS01.xxxx.int) (what's the 2629351 value?? I just want compare the AFAW16-FS01.xxxx.int .
Have i to import a specific plugin, use another syntax? I tried FQDNValueSTR = FQDNValue.ToString() but it's not working....
Thank you !!
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.