Advertisement
atelbor

[GRVY] Issues

Oct 7th, 2022
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /************************/
  2. /*   GROOVY - Issues    */
  3. /************************/
  4.  
  5. // Obtener una issue por su key
  6. // Metodos de la issue
  7. // Obtener y filtrar las subtareas de una issue
  8. // Transicionar una issue
  9. // Clonar una issue
  10.  
  11. /************************************************************************/
  12.  
  13. // Obtener una issue por su key
  14. def issue = ComponentAccessor.getIssueManager().getIssueObject("XEMA-6426")
  15.  
  16. // Metodos de la issue
  17. issue.getKey()
  18. issue.getStatus().getName()
  19. issue.getReporter()
  20. /************************************/
  21.  
  22. // Obtener y filtrar las subtareas de una issue
  23. def subTaskIssues = subTaskManager.getSubTaskObjects(issue)
  24. def subTaskIssuesApproval = subTaskIssues.find { subTaskIssue ->
  25.     subTaskIssue.getIssueType().getName().equals("Approval")
  26. }.collect()
  27. .....  
  28. if (subTaskIssuesApproval.isEmpty()) { ..... }
  29. /************************************/
  30.  
  31. // Transicionar una issue
  32. def transitionIdDone = 31
  33. def transitionOptions = new TransitionOptions.Builder()
  34. def validationResult = issueService.validateTransition(userLogged, issue.getId(), transitionIdDone,
  35.         issueService.newIssueInputParameters(), transitionOptions)
  36. if (validationResult.isValid()) {
  37.     issueService.transition(userLogged, validationResult)
  38. }
  39. /************************************/
  40.  
  41. // Clonar una issue
  42. def adminUser = ComponentAccessor.getUserManager().getUserByName("admin")
  43. def clone = ComponentAccessor.issueFactory.cloneIssueWithAllFields(issue)
  44. clone.setReporter(adminUser)
  45. clone.setAssignee(null)
  46. clone.setCreated(new Timestamp(System.currentTimeMillis()))
  47. clone.setResolutionDate(null)
  48. clone.setUpdated(null)
  49. def issueCloned = ComponentAccessor.issueManager.createIssueObject(adminUser, clone)
  50. /************************************/
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement