Отправить примечания к выпуску заинтересованным лицам - malikovalibek/groovyForJira GitHub Wiki

Обзор Отправьте список проблем в версии выпуска их репортерам, уполномоченным или участникам настраиваемого поля (заинтересованным лицам). Каждая заинтересованная сторона получает уведомление о проблемах, в которых они участвуют.

пример Как менеджер проекта, я хочу, чтобы заинтересованные стороны были проинформированы о выходе новой версии. Я могу настроить этот скрипт для отправки настраиваемого электронного письма репортерам по каждой проблеме.

Хорошо знать Для этого скрипта требуется плагин Email This issue . Свяжите этот сценарий с прослушивателем событий VersionReleased . Создайте собственный шаблон электронной почты с помощью редактора шаблонов электронной почты для этого выпуска .

import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.event.project.VersionReleaseEvent import com.atlassian.jira.bc.issue.search.SearchService import com.atlassian.jira.web.bean.PagerFilter import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.metainf.jira.plugin.emailissue.api.EmailService import com.metainf.jira.plugin.emailissue.api.EmailDefinitionApi import com.metainf.jira.plugin.emailissue.action.EmailOptions import org.apache.log4j.Level

log.setLevel(Level.INFO)

@WithPlugin("com.metainf.jira.plugin.emailissue")

@PluginModule EmailService emailService

// Get the released version from the associated event final version = (event as VersionReleaseEvent).version // Name of the template to use final templateName = 'Release Notes - per reporter'

//Get reference to Jira API def issueManager = ComponentAccessor.issueManager def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser def searchService = ComponentAccessor.getComponent(SearchService)

// Find issues for the version being released def jqlString = "fixVersion = ${version.id} ORDER BY issuetype, priority DESC, key ASC" def parseResult = searchService.parseQuery(user, jqlString) if (!parseResult.valid) { log.error("Invalid JQL: ${jqlString}") return }

def searchResult = searchService.search(user, parseResult.query, PagerFilter.unlimitedFilter) def issuesInVersion = searchResult.results.collect { issueManager.getIssueObject(it.id) } log.info("Issues in version " + issuesInVersion)

// Group the issues by reporter def issuesByReporter = issuesInVersion.groupBy { issue -> issue.reporter } log.info("Issues by reporter: ${issuesByReporter}")

// Loop through the reporters and send the list of their issues to them issuesByReporter.each { reporter, reporterIssues -> if (!reporterIssues) { return }

// Recipient is the reporter only, but other stakeholders could also receive the emails def recipientsTo = [reporter.emailAddress] // Compose parameters for Email This Issue def email = new EmailDefinitionApi() email.to = recipientsTo email.emailOptions = new EmailOptions() email.emailOptions.emailFormat = 'html' email.emailTemplate = templateName

// Payload is a key-value pair to populate email templates def payload = [issues: reporterIssues, version: version, reporter: reporter] email.payload = payload

// Send the email try { emailService.sendEmail(email) } catch (Exception e) { log.error("An exception was thrown: ${e.message}") } }