从JIRA中提取服务器名称

时间:2012-03-15 12:37:04

标签: jira

我想从JIRA获取服务器名称(pop / Imap邮件服务器)。

我搜索了JIRA API并尝试了几种方法,但是无法做到。

我怎么做?

1 个答案:

答案 0 :(得分:1)

要实现这一点,您需要首先从JIRA获取MailServerManager的实例,以下Groovy片段显示了如何实现此目的:

import com.atlassian.jira.ComponentManager
import com.atlassian.mail.server.MailServerManager

componentManager = ComponentManager.getInstance()
mailServerManager = componentManager.getMailServerManager()

要获取默认SMTPMailServer的SMTP服务器的主机名,以下Groovy片段将显示如何:

import com.atlassian.jira.ComponentManager
import com.atlassian.mail.server.MailServerManager

componentManager = ComponentManager.getInstance()
mailServerManager = componentManager.getMailServerManager()
mailServer = mailServerManager.getDefaultSMTPMailServer()
return mailServer.getHostname()

获取默认POPMailServer的主机名如下:

import com.atlassian.jira.ComponentManager
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.server.SMTPMailServer

componentManager = ComponentManager.getInstance()
mailServerManager = componentManager.getMailServerManager()
mailServer = mailServerManager.getDefaultPopMailServer()
return mailServer.getHostname()

您要引用的JIRA API中的类是: