SOLVED: I want to automatically populate epic link value from the Issue field's epic link

Vishwas Shah June 26, 2020

I have one Epic "EPIC1"

EPIC1 has the Story linked to it "STORY1"

Now, when I am raising a bug and choosing "STORY1" under "Issues" field then the "Epic Link" field should also automatically be filled in based on what is chosen as epic link in "STORY1"

So, here while raising a bug, the epic link should be automatically be chosen/selected as "EPIC1" since I have selected "Issues" field value as "STORY1"

1 answer

1 accepted

0 votes
Answer accepted
Radek Dostál
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.
June 26, 2020

Can you elaborate on the use case, i.e. why do you want to do this?

Don't get me wrong it could be done with a groovy script based on Create Issue/Edit Issue listeners, but this just sounds like a really bad practice. Just to be clear, if you're linking bugs to stories, and those stories are part of an Epic, then I would assume you are not shipping those bugs in your Epic releases, but rather the stories fixing them? It should in my opinion be either one or the other, but not both, then again depends on the use case, but that's how I'd understand it.

Vishwas Shah June 29, 2020

Thanks Radek for taking some time to look into it. The whole purpose here is that there are many defects the team logs and they forget to enter epic but add the caused by->story.

So we want to populate epics automatically when the caused by->story is added while creating a bug

Radek Dostál
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.
June 30, 2020

Hey Vishwas,

 

When trying this out on Cloud with the out of box Automation I followed this logic:

 - when Bug is created

 - verify if "Linked Issues" contains value; if so then

 - verify if the linked issues contain a standard issue type, and whether any of these have "Epic Link"

 - if so then copy the first linkedIssue's 'Epic Link' value to the Bug's 'Epic Link' field

 

automationRule.png

 

//Advanced edit text

{
"fields": {
"Epic Link": "{{issue.issuelinks.first.outwardIssue.Epic Link}}"
}
}

 

While this seems to work on paper, it obviously has some loopholes because here I am just taking the first outward issue link's issue's Epic Link. I'm not sure how to filter through multiple linked issues and find which one has the most suitable Epic Link otherwise - what I mean is this is not perfect, but just an idea how this might work the quickest way.

 

Personally I would say that to implement all the conditions, checks and logic, Automation tab itself might not suffice (I honestly kind of doubt it will cover all scenarios).

So myself I would rather script this with another plugin, that can use native Jira's API to go through the linked issues and do additional checks from them.

 

So for example, I use ScriptRunner plugin a lot (https://marketplace.atlassian.com/apps/6820/scriptrunner-for-jira?hosting=cloud&tab=overview) and with a groovy script, you could iterate through all linked issues until you find the most suitable Epic Link to use and copy to the Bug.

 

There are however many other plugins not just ScriptRunner, so I won't push any code here for now. Apart from the out of box Automation tab itself, this could be implemented as a workflow post-function on create, or a listener.

 

If I'm not totally off the rails here, is this somewhat similar to what you were looking for? If so then I suppose it comes down to whether the basic Automation rules can suffice, or whether you will need to look into some more extensive options to be able to filter through the linked issues and decide which value to copy.

 

I might be able to help a bit better depending on the filtering requirements and plugins that you have available,

 

Thanks,

Radek

Vishwas Shah July 2, 2020

Thank Radek, you understand the issue correctly and I am fine with basic automation approach you suggested.

However when this rule runs it is giving me an error-  (Epic with key '' does not exist.)

Any help here is highly appreciated. Thanks

Radek Dostál
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.
July 2, 2020

I've had that error a few times as well before I settled down on

{{issue.issuelinks.first.outwardIssue.Epic Link}}

 

Can you send a screenshot of the edit component page for comparison?

If it is finding null then my thinking here is either the edit settings are incorrect, or the "first outward issue" does not have any 'Epic Link' value.

 

I was testing this with Epic <-Epic Link-> Story <-issueLink-> Bug (newly created)

 

Edit: One more thing came to mind, the rule actor - does the user have browse access to the linked Story? I assume yes but could be another reason why it would find null.

Vishwas Shah July 2, 2020

Sorry, I didn't get the meaning of "edit component page for comparison?". From where can that be found?

The other point of rule actor - Yes, I am the one who is creating the rule and I am the site admin with access to that project/story

Vishwas Shah July 7, 2020

This solved the problem: 

{{issue.issuelinks.first.inwardIssue.Epic Link}}

Thanks for all the help Radek 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events