Jira cloud - changing fix version of story whenever epic fix version is changed

praneet pyati January 11, 2018

Hello!

I have a requirement where I need to change the fix version of stories under the epic whenever the epic fix version is changed.

How do I achieve this requirement.

This is on Jira cloud.

 

Appreciate your response.

2 answers

0 votes
praneet.pyati December 7, 2018

@Deepali Bagul

try this out, this works for me..

def epicKey = issue.key
 
if (!epicKey) {
    return false;
}
 
def epicFixVersions = get('/rest/api/2/issue/' + epicKey)
        .header('Content-Type', 'application/json')
        .asObject(Object)

def issType = epicFixVersions.body.fields.issuetype.name
println(issType)

if (issType!='Epic') {
    return false;
}
def fixVersion = epicFixVersions.body.fields.fixVersions.name

def result1 = get('/rest/api/2/search?jql=cf[10003]=' + epicKey)
        .header('Content-Type', 'application/json')
        .asObject(Object)
def resulttotal = result1.body.total
for (def i=0;i<resulttotal;i++)
{
    def isStatus = result1.body.issues.fields.status.name.value[i]
    if("$isStatus" != "Done" || "$isStatus" != "Closed")
    {
        def result = put('/rest/api/2/issue/' + result1.body.issues.key[i])
        .header('Content-Type', 'application/json')
        .body([
            fields:[
                fixVersions: [[name:fixVersion[0]], [name:fixVersion[1]], [name:fixVersion[2]]]
            ]
        ]).asString()
    }
}
}

0 votes
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 12, 2018

You can do this with Script runner for Cloud. Here's the sample code. Basically you would need to use script listener to list for fixVersion change events and then update the same version on child stories. 

https://michaelheap.com/jira-cloud-scriptrunner/

praneet pyati January 12, 2018

Thank you for your reply but I do not understand what you are trying to pull when you say the below in the first line

customfield_10003
praneet pyati January 12, 2018

Ok I now get it that the epic-name is being found at the customfield_10003 but this holds good when a story is created for an epic and the fix version is set automatically.

But, my original requirement was, whenever EPIC fixVersion is changed, all the associated stories fix version should change. This does not work with the given script.

Any help on achieving it is much appreciated :) 

praneet pyati January 15, 2018

@Tarun Sapra can anyone please help?

Deepali Bagul December 6, 2018

@praneet pyati @Tarun Sapra

Were able to  resolved it. I am facing the same issue. Thanks in advance.

Regards,

Deepali Bagul

Tarun Sapra
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 7, 2018

Hello @Deepali Bagul

The code in the link is the exact sample of what needs to be done, can you please share what is the problem that you are facing?

Suggest an answer

Log in or Sign up to answer