SHARE
TWEET

Untitled

a guest Jan 23rd, 2020 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import com.atlassian.jira.component.ComponentAccessor
  2. import com.atlassian.jira.user.ApplicationUser
  3. import com.atlassian.jira.issue.fields.config.FieldConfig
  4. import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
  5. import java.text.SimpleDateFormat
  6. import org.joda.time.DateTime
  7. import org.apache.log4j.Level
  8. import org.apache.log4j.Logger
  9. log = Logger.getLogger("com.tvpro.CreateIssue")
  10. log.setLevel(Level.DEBUG)
  11.  
  12.  
  13. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MMM/yy HH:mm")
  14. //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  15. def linkMgr = ComponentAccessor.getIssueLinkManager()
  16. def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("PP1-18842")
  17. def customField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11601")
  18. def dataVihodaEfira = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11504") //Дата выхода рубрики в эфир
  19. //def dataVihodaEfiraValue = dataVihodaEfira.getValue(issue)
  20. //def dataVihodaEfiraValue = new DateTime(dataVihodaEfira.getValue(issue))
  21. date = simpleDateFormat.format(dataVihodaEfira.getValue(issue))
  22. //log.debug("Дата выхода рубрики в эфир: " + dataVihodaEfiraValue)
  23. def rubrika = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10501") //Рубрика
  24. def rubrikaValue = rubrika.getValue(issue)
  25. log.debug("Рубрика: " + rubrikaValue)
  26. def znachimost = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11508") //Значимость
  27. def znachimostValue = znachimost.getValue(issue)
  28. log.debug("Значимость: " + znachimostValue)
  29. def graficaDescription = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11502") // Графика - описание идеи/расписание
  30. def graficaDescriptionValue = graficaDescription.getValue(issue)
  31. log.debug("Графика - описание идеи/расписание: " + graficaDescriptionValue)
  32. def valueCF = customField.getValue(issue)*.value
  33.    
  34. if ("Моушен" in valueCF) {
  35.  
  36.     def issueTypeName = "Оперативная графика"
  37.     //def summary = "Groovy Sunday 4"
  38.     def issueService = ComponentAccessor.issueService
  39.     def constantsManager = ComponentAccessor.constantsManager
  40.     def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
  41.     def projectId = ComponentAccessor.projectManager.getProjectByCurrentKey("SDTEST")
  42.     log.debug(projectId.getId())
  43.     def issueType = constantsManager.allIssueTypeObjects.findByName(issueTypeName)
  44.     log.debug(issueType.id)
  45.     def reporter = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
  46.     log.debug(reporter.getKey())
  47.     def priority = constantsManager.priorities.findByName("Major") ?: constantsManager.defaultPriority
  48.     log.debug(priority.id)
  49.     def issueInputParameters = issueService.newIssueInputParameters().with {
  50.         setProjectId(projectId.getId())
  51.         setIssueTypeId(issueType.id)
  52.         setReporterId(reporter.getKey())
  53.         setSummary(issue.summary)
  54.         setPriorityId(priority.id)
  55.         setDescription(graficaDescriptionValue)
  56.         addCustomFieldValue("customfield_11504", date)
  57.         //addCustomFieldValue("customfield_10501", rubrikaValue)
  58.         //addCustomFieldValue("customfield_11508", znachimostValue)
  59.         //addCustomFieldValue("customfield_13503", "Шаблоны")
  60.        
  61.     }
  62.     def validationResult = issueService.validateCreate(loggedInUser, issueInputParameters)    
  63.     def result = issueService.create(loggedInUser, validationResult)
  64.     log.debug(result.issue.id)
  65.     linkMgr.createIssueLink(issue.id, result.issue.id, 10000, 1, loggedInUser)
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top