Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.atlassian.jira.component.ComponentAccessor
- import com.atlassian.jira.user.ApplicationUser
- import com.atlassian.jira.issue.fields.config.FieldConfig
- import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
- import com.atlassian.jira.issue.customfields.option.OptionsImpl
- import java.text.SimpleDateFormat
- import org.apache.log4j.Level
- import org.apache.log4j.Logger
- log = Logger.getLogger("com.tvpro.CreateIssue")
- log.setLevel(Level.DEBUG)
- def locale = ComponentAccessor.applicationProperties.defaultLocale
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MMM/yy HH:mm", locale)
- def linkMgr = ComponentAccessor.getIssueLinkManager()
- def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("PP1-18842")
- def customField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11601")
- def dataVihodaEfira = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11504") //Дата выхода рубрики в эфир
- def dataVihodaEfiraValue = simpleDateFormat.format(dataVihodaEfira.getValue(issue))
- log.debug("Дата выхода рубрики в эфир: " + dataVihodaEfiraValue)
- def rubrika = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10501") //Рубрика
- def rubrikaValue = rubrika.getValue(issue)?.optionId
- log.debug("Рубрика: " + rubrikaValue)
- def znachimost = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11508") //Значимость
- def znachimostValue = znachimost.getValue(issue)?.optionId
- log.debug("Значимость: " + znachimostValue)
- def graficaDescription = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11502") // Графика - описание идеи/расписание
- def graficaDescriptionValue = graficaDescription.getValue(issue)
- log.debug("Графика - описание идеи/расписание: " + graficaDescriptionValue)
- def valueCF = customField.getValue(issue)*.value
- if ("Моушен" in valueCF) {
- def issueTypeName = "Оперативная графика"
- //def summary = "Groovy Sunday 4"
- def issueService = ComponentAccessor.issueService
- def constantsManager = ComponentAccessor.constantsManager
- def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
- def projectId = ComponentAccessor.projectManager.getProjectByCurrentKey("SDTEST")
- log.debug(projectId.getId())
- def issueType = constantsManager.allIssueTypeObjects.findByName(issueTypeName)
- log.debug(issueType.id)
- def reporter = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
- log.debug(reporter.getKey())
- def priority = constantsManager.priorities.findByName("Major") ?: constantsManager.defaultPriority
- log.debug(priority.id)
- def issueInputParameters = issueService.newIssueInputParameters().with {
- setProjectId(projectId.getId())
- setIssueTypeId(issueType.id)
- setReporterId(reporter.getKey())
- setSummary(issue.summary)
- setPriorityId(priority.id)
- setDescription(graficaDescriptionValue)
- addCustomFieldValue("customfield_11504", dataVihodaEfiraValue)
- addCustomFieldValue("customfield_10501", rubrikaValue)
- addCustomFieldValue("customfield_11508", znachimostValue)
- //addCustomFieldValue("customfield_13503", "Шаблоны")
- }
- def validationResult = issueService.validateCreate(loggedInUser, issueInputParameters)
- log.debug(validationResult.errorCollection)
- def result = issueService.create(loggedInUser, validationResult)
- log.debug(result.issue.id)
- linkMgr.createIssueLink(issue.id, result.issue.id, 10000, 1, loggedInUser)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement