Wiki source code of Doing Automation
Version 5.1 by Normann P. Nielsen on 2026/11/15 15:44
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | Jira can be very efficient, but out of the box no real automation exists.. | ||
| 2 | |||
| 3 | = Interfacing = | ||
| 4 | |||
| 5 | These days several other ways exist: | ||
| 6 | |||
| 7 | |= Script/Type|= Comments | ||
| 8 | | [[Automation App>>https://marketplace.atlassian.com/apps/1215460/automation-for-jira?hosting=datacenter&tab=overview]]| Almost standard now-a-days... (and You get it automatically in cloud) | ||
| 9 | Some Apps, like JSU App and [[Script Runner>>https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner]] App offer parts of automation | ||
| 10 | | [[Atlassian CLI>>Main.atlassian.atlassian-confluence.atlassian-cli]]| Can be "integrated via shell calls from script, powershell and other programming languages. | ||
| 11 | As it is java based, it is virtually platform independant, the main downside is that is is slow. | ||
| 12 | | JIRA [[JellyScript>>https://confluence.atlassian.com/display/JIRA/Jelly+Tags]]| See Atlassian (old) samples at: [[https://confluence.atlassian.com/display/JIRA/Jelly+Escalation]] | ||
| 13 | | [[Script Runner>>https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner]] App| See some samples at [[l>>https://jamieechlin.atlassian.net/wiki/display/GRV/Miscellaneous+Groovy+Scripts]][[ibrary.adaptavist.com>>https://library.adaptavist.com]] | ||
| 14 | | REST API| Interfacing with JIRA through webservices - [[REST>>https://docs.atlassian.com/jira/REST/latest/]], The SOAP and XML-RCP is [[deprecated>>https://www.google.dk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&cad=rja&uact=8&ved=0CD8QFjAE&url=https%3A%2F%2Fdeveloper.atlassian.com%2Fdisplay%2FJIRADEV%2FSOAP%2Band%2BXML-RPC%2BAPI%2BDeprecated%2Bin%2BJIRA%2B6.0&ei=UGBoU4HQKoHhygP884CICw&usg=AFQjCNF48gCgzHCIJ6ozwtbYx12Ij-sxOw]] | ||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | = Scheduling = | ||
| 19 | |||
| 20 | The internal JIRA Scheduler implemented in [[Services>>https://confluence.atlassian.com/display/JIRA/Services]] really sucks - only setting is a "pr. minute" count called delay, and this: | ||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | * Resets when JIRA is restarted | ||
| 25 | * Is relative from JIRA Start, so You can't schedule "at midnight" | ||
| 26 | |||
| 27 | |||
| 28 | Hence, use another Scheduler if the timing must be right, like tweaking my [[Making a free JIRA Scheduler>>Main.atlassian.atlassian-jira.making-a-free-jira-scheduler]] or buy [[TheScheduler>>https://marketplace.atlassian.com/plugins/pl.com.tt.jira.plugin.theschedulerpro]] Plugin | ||
| 29 | |||
| 30 | Or create Your own.... | ||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | = Hiding Auto Transitions = | ||
| 35 | |||
| 36 | === Problem === | ||
| 37 | Often, You want the Automation and the User to perform the same transitions, or the Automation to do extra "invisible" stuff, - This can be tricky, also because any validations not handled in the transitionscript will cause a fail: | ||
| 38 | |||
| 39 | |||
| 40 | {{code}} | ||
| 41 | 2014-05-05 22:46:30,674 QuartzScheduler_Worker-3 INFO ServiceRunner CloseResolvedIssues [jira.jelly.service.JellyService] JellyService.run | ||
| 42 | 2014-05-05 22:46:30,803 QuartzScheduler_Worker-3 ERROR anonymous CloseResolvedIssues [jira.jelly.service.JellyService] file:/pack/jira-jelly/support-closeresolved.xml:48:125: <jira:TransitionWorkflow> The following problems were found: | ||
| 43 | customfield_12922: ITIL Tag is required. | ||
| 44 | org.apache.commons.jelly.JellyTagException: file:/pack/jira-jelly/support-closeresolved.xml:48:125: <jira:TransitionWorkflow> The following problems were found: | ||
| 45 | customfield_12922: ITIL Tag is required. | ||
| 46 | at com.atlassian.jira.jelly.tag.JellyUtils.processErrorCollection(JellyUtils.java:24) | ||
| 47 | at com.atlassian.jira.jelly.tag.issue.TransitionWorkflow.doTag(TransitionWorkflow.java:133) | ||
| 48 | at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247) | ||
| 49 | {{/code}} | ||
| 50 | |||
| 51 | |||
| 52 | |||
| 53 | === Solution === | ||
| 54 | Create an "automationservices" group | ||
| 55 | |||
| 56 | Create a Transition that can only be done by users in that group: | ||
| 57 | |||
| 58 | [[image:Screen Shot 2014-05-05 at 23.47.00.png||width="800"||alt="Screen Shot 2014-05-05 at 23.47.00.png"]] | ||
| 59 | |||
| 60 | Hidden: | ||
| 61 | |||
| 62 | [[image:Screen Shot 2014-05-05 at 23.48.07.png||width="557"||height="183"||alt="Screen Shot 2014-05-05 at 23.48.07.png"]] | ||
| 63 | |||
| 64 | Setting fields correctly: | ||
| 65 | |||
| 66 | [[image:Screen Shot 2014-05-05 at 23.54.48.png||width="580"||alt="Screen Shot 2014-05-05 at 23.54.48.png"]] | ||
| 67 | |||
| 68 | {{error}}If You encounter this error in the logs: | ||
| 69 | |||
| 70 | |||
| 71 | {{code}} | ||
| 72 | 2014-06-10 08:01:43,716 QuartzScheduler_Worker-2 WARN automaticservices CloseinactiveSupportIssues [jelly.tags.log.WarnTag] Inactivating issue MYPROJECT-151 | ||
| 73 | 2014-06-10 08:01:43,825 QuartzScheduler_Worker-2 ERROR anonymous CloseinactiveSupportIssues [jira.jelly.service.JellyService] file:/pack/jira-jelly/support-closeinactivate.xml:48:145: <jira:TransitionWorkflow> Field 'resolution' can not be set on action with no screen | ||
| 74 | org.apache.commons.jelly.JellyTagException: file:/pack/jira-jelly/support-closeinactivate.xml:48:145: <jira:TransitionWorkflow> Field 'resolution' can not be set on action with no screen | ||
| 75 | {{/code}} | ||
| 76 | |||
| 77 | This is typically due to the script is a copy/similarity of [[https://confluence.atlassian.com/display/JIRA/Jelly+Escalation]] and the line: | ||
| 78 | |||
| 79 | |||
| 80 | {{code}} | ||
| 81 | <jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" comment="${comment}" resolution="Customer Timeout"/> | ||
| 82 | {{/code}} | ||
| 83 | |||
| 84 | Setting a field on the Jelly "jira:TransitionWorkflow" requires a screen with the field, therefore - set it in the Post Function{{/error}} | ||
| 85 | |||
| 86 | {{error}}A real-life example: | ||
| 87 | |||
| 88 | I created an onComment Listener in Groovy, that transistet Issue when a Comment came in, a code snippet is: | ||
| 89 | |||
| 90 | |||
| 91 | {{code}} | ||
| 92 | workflowTransitionUtil.setUsername(currentuser); | ||
| 93 | workflowTransitionUtil.setAction (transition) | ||
| 94 | // Validate and transition issue | ||
| 95 | workflowTransitionUtil.validate(); | ||
| 96 | workflowTransitionUtil.progress(); | ||
| 97 | {{/code}} | ||
| 98 | |||
| 99 | This code is valid, but in the "Post Function" of the Transition was: | ||
| 100 | |||
| 101 | |||
| 102 | {{code}} | ||
| 103 | Fire a Issue Commented event that can be processed by the listeners. | ||
| 104 | {{/code}} | ||
| 105 | |||
| 106 | Hence, the script re-fired itself, which is not good...{{/error}} |