Hi community!
I'm trying to write a validator script that checks if an Epic got linked issues.
if yes - the workflow transition can move, otherwise it sends an error message.
so far I got this but it's not working for me. (Using Jira server).
Code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.opensymphony.workflow.InvalidInputException
// Allow logging for debug and tracking purposes
import org.apache.log4j.Level
import org.apache.log4j.Logger
// Setup the log and leave a message to show what we're doing
Logger logger = log
logger.setLevel( Level.ERROR )
logger.debug( "$scriptCode Triggered by $issue.key" )
def passesCondition = true
if (issue.linkedIssues.size() > 0)
{
IssueLinkManager issueLinkManager = ComponentAccessor.issueLinkManager
def found = issueLinkManager.getOutwardLinks(issue.id).any{ }
logger.debug( "$scriptCode Found = $found " )
if (found) {
logger.debug( "$scriptCode return false" )
passesCondition = false
invalidInputException = new InvalidInputException("Please create issues")
} else {
logger.debug( "$scriptCode return true" )
passesCondition = true
}
}
else
{
passesCondition = true
}
Are you looking for your Epic to have regular issue links?
Or are you looking for "epic link" or "issues in epic" link?
Because those are different.
The IssueLinkManager will only get you issue links like "Cloned By", "Related To", "Blocks" etc.
If you want to look to see if the epic has issues in the epic link, then you need to EpicLInkManager
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.greenhopper.manager.issuelink.EpicLinkManager
@WithPlugin("com.pyxis.greenhopper.jira") agilePlugin
@JiraAgileBean EpicLinkManager epicLinkManager
def issuesInEpic = epicLinkManager.getIssuesInEpic(issue)
if(issuesInEpic) {
log.debug "${issuesInEpic.size()} issues were linked to this epic."
return true
} else {
log.debug "No issues are linked to this epic"
return false
}
Hi @Peter-Dave Sheehan thanks for your response.
I used:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.