Отправить примечания к выпуску заинтересованным сторонам проекта - 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.security.roles.ProjectRoleManager 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
@WithPlugin("com.metainf.jira.plugin.emailissue")
@PluginModule EmailService emailService
// Get the released version from the associated event final version = (event as VersionReleaseEvent).version final project = version.project //Name of the template to use final templateName = "Release Notes" //Role send notification to final projectRoleToNotify = 'Administrators'
//Get reference to Jira API def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager) def issueManager = ComponentAccessor.issueManager def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser def searchService = ComponentAccessor.getComponent(SearchService)
// Determine the project role members to send email to def projectRole = projectRoleManager.getProjectRole(projectRoleToNotify) def recipientsTo = projectRoleManager.getProjectRoleActors(projectRole, project).users*.emailAddress
// 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) }
// 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: issuesInVersion, version: version] email.payload = payload
// Send the email try { emailService.sendEmail(email) } catch (Exception e) { log.error("An exception was thrown: ${e.message}") }