Перенести проблему с помощью входных параметров задачи - malikovalibek/groovyForJira GitHub Wiki
Обзор
Используйте входные параметры при переходе к проблеме. В этом примере изменяются параметры и проверяются переходы для каждой подзадачи для указанной проблемы.
пример
Я менеджер по продукту. Я хочу создать подзадачи родительской задачи с такими же характеристиками, когда я переведу родительскую задачу в состояние «Выполняется». С помощью этой функции публикации все подзадачи родительской задачи автоматически получат то же значение, что и родительская задача, когда родительская задача перейдет в состояние «Выполняется».
Хорошо знать
Используйте этот скрипт в качестве пост-функции, связанной с шагом In Progress . Подзадачи должны быть созданы до перехода родительской задачи в состояние «Выполняется».
С участием
ScriptRunner для Jira от Adaptavist
Создано 2 года назад , Обновлено 3 месяца назад
Код сервера Код центра обработки данных
Требования
JiraJira (7,7 - 8,6)
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.ApplicationUser
import java.text.SimpleDateFormat
// the step you want sub-tasks to be transitioned to final actionName = 'In Progress'
// the name of the 'Date' custom field final startCustomFieldName = 'Projected Start'
// the name of the 'User Picker (single user)' custom field final projectManagerCustomFieldName = 'Project Manager'
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser def issueService = ComponentAccessor.issueService def customFieldManager = ComponentAccessor.customFieldManager def workflowManager = ComponentAccessor.workflowManager
def simpleDateFormat = new SimpleDateFormat('dd/MMM/yy') def projectedStartCustomField = customFieldManager.getCustomFieldObjects(issue).findByName(startCustomFieldName) assert projectedStartCustomField: "Could not find custom field with name $startCustomFieldName"
def projectManagerCustomField = customFieldManager.getCustomFieldObjects(issue).findByName(projectManagerCustomFieldName) assert projectManagerCustomField: "Could not find custom field with name $projectManagerCustomFieldName"
def workflowActionId = workflowManager.getWorkflow(issue).allActions.findByName(actionName)?.id
issue.subTaskObjects.each { subtask -> def issueInputParameters = issueService.newIssueInputParameters() issueInputParameters.setSkipScreenCheck(true)
issueInputParameters.setResolutionId(issue.resolutionId)
issueInputParameters.setSummary(issue.summary)
issueInputParameters.setDescription(issue.description)
issueInputParameters.setAssigneeId(issue.assigneeId)
// copy the value of the 'Projected Start' custom field from the parent issue
def projectedStartCustomFieldValue = simpleDateFormat.format(issue.getCustomFieldValue(projectedStartCustomField))
issueInputParameters.addCustomFieldValue(projectedStartCustomField.id, projectedStartCustomFieldValue)
// copy the value of the 'Project Manager' custom field from the parent issue
def projectManagerCustomFieldValue = issue.getCustomFieldValue(projectManagerCustomField) as ApplicationUser
issueInputParameters.addCustomFieldValue(projectManagerCustomField.id, projectManagerCustomFieldValue?.key)
def transitionValidationResult = issueService.validateTransition(currentUser, subtask.id, workflowActionId, issueInputParameters)
assert transitionValidationResult.isValid(): transitionValidationResult.errorCollection
def transitionResult = issueService.transition(currentUser, transitionValidationResult)
assert transitionResult.isValid(): transitionResult.errorCollection
}