Notifications JIRA-向匿名用户发送电子邮件

Notifications JIRA-向匿名用户发送电子邮件,notifications,jira,issue-tracking,Notifications,Jira,Issue Tracking,我试图找出一种方法,当一个匿名用户通过电子邮件产生问题时,可以向该用户发送电子邮件。我需要的是这个匿名用户在问题被打开、评论和关闭时收到一封通知电子邮件。 根据他们的观点,这只能在创建者已经是JIRA中的用户或者用户将被动态创建的情况下完成。这些都不适合我。 到目前为止,我发现的解决办法是: -这承诺了这一功能,但看起来不稳定,这意味着每次JIRA更新似乎都会中断(至少有一点中断),对我来说没有停机时间是可以接受的 我自己写的剧本是在 我写我自己的剧本没有问题,但我只是想确定我不会重新发明轮子。

我试图找出一种方法,当一个匿名用户通过电子邮件产生问题时,可以向该用户发送电子邮件。我需要的是这个匿名用户在问题被打开、评论和关闭时收到一封通知电子邮件。 根据他们的观点,这只能在创建者已经是JIRA中的用户或者用户将被动态创建的情况下完成。这些都不适合我。 到目前为止,我发现的解决办法是:


  • -这承诺了这一功能,但看起来不稳定,这意味着每次JIRA更新似乎都会中断(至少有一点中断),对我来说没有停机时间是可以接受的
  • 我自己写的剧本是在
  • 我写我自己的剧本没有问题,但我只是想确定我不会重新发明轮子。还有其他的方法吗


    我将非常感谢您的帮助。

    我怀疑JIRA已经内置了这个功能,而且我还没有看到一个插件可以实现它

    我过去调查过这件事,结果一无所获。我怀疑它不是内置的,因为对于许多潜在客户来说,它将允许他们获得10个用户的许可证,但仍然支持数千个用户

    我们改为使用无限制用户许可证


    更新:我想补充一点,你可以写一个脚本来完成这个任务。但是它看起来像是一个PITA,必须为它创建一个自定义侦听器来捕获问题的更改

    我刚刚注意到这个问题。JEMH现已发展成为一个成熟的商业插件,并拥有大量新功能,其中一些功能实际上解决了支持远程“匿名”用户创建问题的问题,基本上将JIRA变成了一个功能齐全的电子邮件帮助台解决方案。具体的模板定制是基于每个事件的

    关于中断,停留在“最新”版本上,开发者绝对没有时间赶上。聪明一点,给所有开发者一个迎头赶上的机会


    不幸的是,由于JEMH对JIRA API的深度进行了测量,破裂很常见,但由于Atlassian将一些核心API稳定在5.0+中,所以现在不太可能发生。还正在开展工作,以提供端到端集成测试,这本身就是一项任务

    下面是我如何使用的,我已经告诉Jira从我的邮箱获取电子邮件,并从中创建问题。然后,在工作流中,我使用以下脚本将发件人的电子邮件和姓名保存到自定义字段中:

    from com.atlassian.jira import ComponentManager
    import re
    cfm = ComponentManager.getInstance().getCustomFieldManager()
    
    # read issue description
    description = issue.getDescription()
    if (description is not None) and ('Created via e-mail received from' in description):
        # extract email and name:
        if ('<' in description) and ('>' in description):
            # pattern [Created via e-mail received from: name <email@company.com>]
            # split it to a list
            description_list = re.split('<|>|:',description)
            list_length = len(description_list)
            for index in range(list_length-1, -1, -1):
                if '@' in description_list[index]:
                    customer_email = description_list[index]
                    customer_name = description_list[index - 1]
                    break
        else:
            # pattern [Created via e-mail received from: email@company.com]
            customer_name = "Sir or Madam"
            # split it to a list  
            description_list = re.split(': |]',description)
            list_length = len(description_list)
            for index in range(list_length-1, -1, -1):
                if '@' in description_list[index]:
                    customer_email = description_list[index]
                    break
    
        # if the name isn't in the right form, switch it's places:
        if (customer_name[0] == '"') and (customer_name[-1] == '"') and (',' in customer_name):
            customer_name = customer_name[1:-1]
            i =  customer_name.index(',')
            customer_name = customer_name[i+2:]+" "+customer_name[:i]
    
        # insert data to issue fields
        issue.setCustomFieldValue(cfm.getCustomFieldObject("customfield_10401"),customer_email)
        issue.setCustomFieldValue(cfm.getCustomFieldObject("customfield_10108"),customer_name)
    
    import smtplib,email
    from smtplib import SMTP 
    from email.MIMEMultipart import MIMEMultipart
    from email.MIMEBase import MIMEBase
    from email.MIMEText import MIMEText
    from email import Encoders
    import os
    import re
    from com.atlassian.jira import ComponentManager
    
    customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
    cfm = ComponentManager.getInstance().getCustomFieldManager()
    
    # read needed fields from the issue
    key = issue.getKey()
    #status = issue.getStatusObject().name
    summary = issue.getSummary()
    project = issue.getProjectObject().name
    
    # read customer email address
    toAddr = issue.getCustomFieldValue(cfm.getCustomFieldObject("customfield_10401"))
    # send mail only if a valid email was entered
    if (toAddr is not None) and (re.match('[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,4}',toAddr)):
        # read customer name
        customerName = issue.getCustomFieldValue(cfm.getCustomFieldObject("customfield_10108"))
        # read template from the disk
        template_file = 'new_case.template'
        f = open(template_file, 'r')
        htmlBody = ""
        for line in f:
            line = line.replace('$$CUSTOMER_NAME',customerName)
            line = line.replace('$$KEY',key)
            line = line.replace('$$PROJECT',project)
            line = line.replace('$$SUMMARY',summary)
            htmlBody += line + '<BR>'
    
    
        smtpserver = 'smtpserver.com'
        to = [toAddr]
        fromAddr = 'jira@email.com'
        subject = "["+key+"] Thank You for Contacting Support team"
        mail_user = 'jira@email.com'
        mail_password = 'password'
    
        # create html email
        html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
        html +='"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">'
        html +='<body style="font-size:12px;font-family:Verdana">'
        html +='<p align="center"><img src="http://path/to/company_logo.jpg" alt="logo"></p> '
        html +='<p>'+htmlBody+'</p>'
        html +='</body></html>'
    
        emailMsg = email.MIMEMultipart.MIMEMultipart('alternative')
        emailMsg['Subject'] = subject
        emailMsg['From'] = fromAddr
        emailMsg['To'] = ', '.join(to)
        emailMsg.attach(email.mime.text.MIMEText(html,'html'))
    
        # Send the email
        s = SMTP(smtpserver) # ip or domain name of smtp server
        s.login(mail_user, mail_password)   
        s.sendmail(fromAddr, [to], emailMsg.as_string())
        s.quit()
    
        # add sent mail to comments
        cm = ComponentManager.getInstance().getCommentManager()
        email_body = htmlBody.replace('<BR>','\n')
        cm.create(issue,'anonymous','Email was sent to the customer ; Subject: '+subject+'\n'+email_body,False)
    

    所有脚本都应附加到工作流,以创建转换。脚本是使用编写的,因此需要安装才能使用。您可以使用向Jira自定义字段中存储的电子邮件发送通知 配置很简单,下面是一个示例:

    谢谢你,杰森,这看起来很有希望。我会调查这件事的。“我不接受停机时间”。当然,在JEMH插件更新之前,你不需要升级吗?我明白你的意思,mdoar,我明白你的意思。然而,JEMH是由一个人开发的,至少从外观上看是由一个人开发的,如果他决定不再支持他的项目,我将被“不可升级”的JIRA困住,不得不再次寻找替代品。
    Dear $$CUSTOMER_NAME,
    
    Thank you for contacting support team.
    
    We will address your case as soon as possible and respond with a solution very quickly.
    
    Issue key $$KEY has been created as a reference for future correspondence.
    
    If you need urgent support please refer to our Frequently Asked Questions page at http://www.example.com/faq.
    
    Thank you,
    
    Support Team
    
    
    Issue key: $$KEY
    Issue subject: $$PROJECT
    Issue summary: $$SUMMARY