jira close as duplicate if linked as duplicate

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016

Hi all,

I have found a way through a grovvy script to make sure when the close with resolution = duplicate that they have an issue linked with outward as duplicate.  

The problem I am having is that the user can still link an issue as duplicate, and it not be closed. 

To do this I go into "More" => Link, and then link as duplicate.  

My user wants to only be able to link as duplicate when closing as duplicate.  Is that possible?   

Here is my verification script that works on the close transition

linkCnt = 0
 
request = webwork.action.ActionContext.getRequest()
if (request) {
    // check for new duplicates link
    linktype = request.getParameter('issuelinks-linktype')
    linkedIssue = request.getParameter('issuelinks-issues')
    if (linktype == 'duplicates' && linkedIssue) linkCnt = 1
}
 
// check for existing duplicates link
if ( issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Duplicate') ) linkCnt += 1
 
// Transition requires one, and only one, duplicates link or the resolution not to be Duplicate
(linkCnt==1) || cfValues['resolution'].toString() != 'Duplicate' 

:

 

2 answers

1 accepted

0 votes
Answer accepted
Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016

Actually JIRA does support it as of 4.4 and that is how we are doing it.  (include Linked Issues on the closing screen to accomplish it)   I was hoping to be able (I am sure I could if  I knew js better) hide the link at all time except if I am on the closing screen.  Though we have many teams using JIRA (Legal, Marketing, etc) and this request is just coming from Engineering.

I guess the real question is now, "How can I search for linked issues", and the answer is JQL tricks plugin allows it.

Jeremy Gaudet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016

But do they support deleting the link if the close operation doesn't work?  And not being able to use that link type elsewhere?

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016

No ,but that is not what I need.  I only need to:

  1. Only allow a resolution to be closed with duplicate if you have an issue linked with duplicate.  The code above.
  2. prevent people from link with duplicate and not closing the issue

    For that one I will create a JQL query to find any non closed issues with a Duplicate link and email (subscribe) that report and that way I am not prevented it but I can slap those on the wrist that do fail to close duplicates.  To do that I believe I will need to install JQL tricks, but that is free so no need for finance (finance is not a fun process for me)

 

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016

Ugh JQL tricks is not free bummer.  Anyone know how to find all issues that have a duplicate link?    I bet I could with the CLI...  hmm...

Jeremy Gaudet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016
Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016

Can you use that in a JQL filter?  Above I have the Script runner validator code already.  I need to create a filter to find anyone who has created a link as Duplicate yet did not close the issue.

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016

Actually it does WOW  thanks Learnt something knew smile

issueFunction in hasLinks('duplicates') 

1 vote
Jeremy Gaudet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016

The best I can think of would be to also disallow closing as anything except Duplicate, if there is an outward duplicate link.  As in, augment your existing validator to something like:

(linkCnt==1 && cfValues['resolution'].toString() == 'Duplicate') || (linkCnt==0 && cfValues['resolution'].toString() != 'Duplicate')

That way if linkCnt is > 1, or the resolution doesn't match the linkCnt, they won't be able to close.

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016

But that would still allow an issue to have a duplicate link but not be closed.

Even if I could have a filter that people could subscribe to that would have any issue that has a duplicate link and is not resolved that would work, but I prefer to prevent this behavior completely.

So I do not want people to link as duplicate without closing the issue.

Jeremy Gaudet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2016

Unfortunately, I can think of no way to do that, unless linking emits an event you can use to trigger a script listener; even then, the listener would have to unlink it, and so the user would not know there was an issue, or close it, which it may not have the context to do. Unless there is a way to disallow linking entirely based on the status, and only allow linking post closure, but then you wouldn't be able to link anything.

I suppose there is likely a javascript option available that could filter the list of available link types.

Fundamentally, this is a chicken/egg scenario.  You can't have it require that it be closed-as-duplicate before linking as duplicate, and also be linked-as-duplicate prior to closing-as-duplicate, that's a circular dependency.  If you could do both at the same time, in the same 'transaction', that would work, conceptually, but it means you have to perform the link (actually, a pending link) in the Close transition, which JIRA doesn't support to my knowledge.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events