I would like to close a issue when ever the issue is linked by duplicate to another issue.
How could this be achieved in JIRA using script runner. Please note that I am currently using JIRA 8.2 .I d not have automation in Jira
When ever the issue is linked to another issue as the duplicate , I would like to triggers an event or have listeners that marks the issue as closed. The issue can be in any status and it if it is updated as marked duplicate in the issue links, I would like to mark the issue as closed.
Hi @Garden16_
For your requirement, I suggest trying something like this:-
import com.atlassian.jira.issue.link.IssueLink def issueLink = event.issueLink as IssueLink if (issueLink.issueLinkType.outward == 'duplicates') { issueLink.sourceObject.transition('Done') { setComment('This is a duplicate') } }
Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Listener configuration:-
This code automatically transitions the issue that has been linked as a duplicate to the Done status.
Once you have created the issue, link it to the duplicate Link Type, and it will automatically transition to done status.
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
Getting static checking error .
The transition to close defect is the last transition. The issue link may be used at any different statuses. Is a transition required to close defect from all statuses
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ERROR [runner.AbstractScriptListener]: *************************************************************************************
ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent, file: null
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.transition() is applicable for argument types: (String, Script214$_run_closure1) values: [Closed Defect, Script214$_run_closure1@1aacbead]
at Script214.run(Script214.groovy:6)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Garden16_
Could you please specify what version of Jira and ScriptRunner you are currently using?
I have run the test with Jira 9.6.0 and the latest version of ScriptRunner, i.e. 8.17.0, and I am not encountering any issues.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Garden16_
It seems you are using a very old and no longer supported version of Jira.
The .transition('Done') is based on ScriptRunner's HAPI feature, which is used to simplify the code.
You cannot access this in the current Jira and ScriptRunner versions you are using.
I suggest upgrading your Jira instance to at least 8.20.0 and upgrading your ScriptRunner plugin to the latest release, i.e. 8.17.0, so you will be able to use the new features.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Garden16_
Unfortunately, with the older version of Jira and ScriptRunner, this is not doable via Listener.
You will need to use the Post-Function for it.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.