SHOW:
|
|
- or go back to the newest paste.
1 | - | /***********************/ |
1 | + | /************************/ |
2 | - | /* GROOVY - Varios */ |
2 | + | /* GROOVY - Issues */ |
3 | - | /***********************/ |
3 | + | /************************/ |
4 | ||
5 | - | // Lanzar excepción (validador) |
5 | + | // Obtener una issue por su key |
6 | - | // Obtener el action que se está ejecutando en una PF |
6 | + | // Metodos de la issue |
7 | - | // Mostrar popup flag |
7 | + | // Obtener y filtrar las subtareas de una issue |
8 | // Transicionar una issue | |
9 | // Clonar una issue | |
10 | ||
11 | - | // Lanzar excepción (validador) |
11 | + | |
12 | - | throw new InvalidInputException("customfield_20109", "Default value must be modified") |
12 | + | |
13 | // Obtener una issue por su key | |
14 | def issue = ComponentAccessor.getIssueManager().getIssueObject("XEMA-6426") | |
15 | - | // Obtener el action que se está ejecutando en una PF |
15 | + | |
16 | - | def actionID = transientVars["actionId"] |
16 | + | |
17 | - | JiraWorkflow workflow = ComponentAccessor.getWorkflowManager().getWorkflow(issue) |
17 | + | // Metodos de la issue |
18 | - | def wfd = workflow.getDescriptor() |
18 | + | issue.getKey() |
19 | - | def actionName = wfd.getAction(transientVars["actionId"]).getName() |
19 | + | issue.getStatus().getName() |
20 | issue.getReporter() | |
21 | /************************************/ | |
22 | - | // Mostrar popup flag |
22 | + | |
23 | - | import com.onresolve.scriptrunner.runner.util.UserMessageUtil |
23 | + | // Obtener y filtrar las subtareas de una issue |
24 | - | UserMessageUtil.success('Good job! ') |
24 | + | def subTaskIssues = subTaskManager.getSubTaskObjects(issue) |
25 | - | UserMessageUtil.info("Something interesting") |
25 | + | def subTaskIssuesApproval = subTaskIssues.find { subTaskIssue -> |
26 | - | UserMessageUtil.warning("Danger") |
26 | + | subTaskIssue.getIssueType().getName().equals("Approval") |
27 | - | UserMessageUtil.error("Error") |
27 | + | }.collect() |
28 | ..... | |
29 | - | //// Opcion 2 |
29 | + | if (subTaskIssuesApproval.isEmpty()) { ..... } |
30 | - | import com.onresolve.scriptrunner.runner.util.UserMessageUtil |
30 | + | |
31 | - | def flag = [ |
31 | + | |
32 | - | type: "warning", // Other possible options are "info", "success", "error" |
32 | + | // Transicionar una issue |
33 | - | body: "Please Request for retrofit codes if not already done.", |
33 | + | def transitionIdDone = 31 |
34 | - | close: "manual", // Other option is "auto" |
34 | + | def transitionOptions = new TransitionOptions.Builder() |
35 | - | ] |
35 | + | def validationResult = issueService.validateTransition(userLogged, issue.getId(), transitionIdDone, |
36 | - | UserMessageUtil.flag(flag) |
36 | + | issueService.newIssueInputParameters(), transitionOptions) |
37 | if (validationResult.isValid()) { | |
38 | issueService.transition(userLogged, validationResult) | |
39 | } | |
40 | /************************************/ | |
41 | ||
42 | // Clonar una issue | |
43 | def adminUser = ComponentAccessor.getUserManager().getUserByName("admin") | |
44 | def clone = ComponentAccessor.issueFactory.cloneIssueWithAllFields(issue) | |
45 | clone.setReporter(adminUser) | |
46 | clone.setAssignee(null) | |
47 | clone.setCreated(new Timestamp(System.currentTimeMillis())) | |
48 | clone.setResolutionDate(null) | |
49 | clone.setUpdated(null) | |
50 | def issueCloned = ComponentAccessor.issueManager.createIssueObject(adminUser, clone) | |
51 | /************************************/ | |
52 |