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

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
Tarun Sapra Community Champion Jan 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/

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

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

@Tarun Sapra can anyone please help?

@praneet pyati @Tarun Sapra

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

Regards,

Deepali Bagul

Tarun Sapra Community Champion Dec 07, 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?

@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()
    }
}
}

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

807 views 3 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you