Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Need to close a issue type when the issue is marked as duplicate or is duplicate in JIRA

Garden16_ December 5, 2023

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.

 

 

 

 

1 answer

1 vote
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 8, 2023

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:-

listener_config.png

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

Garden16_ December 11, 2023

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 

 

issue duplicate.PNG

Garden16_ December 11, 2023

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)

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 11, 2023

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

Garden16_ December 12, 2023

We have script runner Version:

6.56.0 Data center 
and JIRA  8.0.1
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 12, 2023

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

Garden16_ December 13, 2023

Please share the code based my current JIRA version.

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 13, 2023

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

Suggest an answer

Log in or Sign up to answer