Forums

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

JMWE Postfunction issue with conditional execution

srikanth duggineni June 13, 2018

Hi, 

I learned that JMWE plugin post function - "Transition Parent Issue" based on linked issues statuses has an issue with Jira 7.x when parent issue transition is having conditions/ validations. https://jira.atlassian.com/browse/JRASERVER-44681

So i have written a groovy script that validates the all linked issue statuses and do the transition on Epic issue. (In My case all issue types have the same workflow and Epic has the different workflow)

1. Navigate to a linked issueType workflow 

2. Add a postfunction - (Transition linked issues (JMWE add-on) Function)

3. Add the transition ID

4. Issue Link is selected as 'has Epic (from Story to Epic)'

5. Added following script as groovy condition 

At the end i can verify that, even i !=noOfIssues, still the current transition executing the Epic transition. Could you please help on this ? 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CommentSystemField
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.fugue.Option
import com.atlassian.jira.issue.Issue
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.web.bean.PagerFilter


def issue = issue as Issue


def customFieldManager = ComponentAccessor.getCustomFieldManager()

def epicLinkCf = customFieldManager.getCustomFieldObjectByName("Epic Link")

def epicLink = issue.getCustomFieldValue(epicLinkCf) as Issue

def epicLinkManagerImpl = getBean("epicLinkManagerImpl");
issuesInEpic = epicLinkManagerImpl.getIssuesInEpic(epicLink)
def noOfIssues = issuesInEpic.size()

def i = 0
for (child in issuesInEpic) {
def status = child.getStatus().getName()


if ((status.equalsIgnoreCase('ABANDONED'))||(status.equalsIgnoreCase('REJECTED'))||(status.equalsIgnoreCase('NOT APPLICABLE'))){
i = i+1
}

}


if (i.equals(noOfIssues)){
return true
}
else {
return false
}

def getBean(String beanId)
{
def ghPlugin = ComponentAccessor.getPluginAccessor().getEnabledPlugin("com.pyxis.greenhopper.jira")
def descriptor = ghPlugin.getModuleDescriptor("greenhopper-launcher")
def applicationContext = descriptor.getModule().greenHopperCacheManager.applicationContext
def beanInstance = applicationContext.getBean(beanId)
return beanInstance;
}

 

1 answer

1 accepted

0 votes
Answer accepted
srikanth duggineni June 18, 2018

Hey, the above code is working without any issues. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events