For Example: If i have 3 stories linked to a Feature and one them moved to "To do" to "In Progress" the Feature should also change to "In Progress".
Same way if all the three stories moved to "Done" the Feature should also changed to "Done".
We don't have any customization Add-ons integrated with JIRA except Script Runner.
I am new to Script Runner and Groovy script.
How to achieve this with Script Runner?
I tried to find a solution for this in online and script runner documentation. I couldn't find way to do this.
Any help would be greatly appreciated!
Thanks,
Mani
In getLinkedIssues method ,first parameter you are passing is it.sourceObject . In my scenario what exactly the parameter value would be?
In same way it.destinationObject what value do i need to pass, if it has to be done dynamically.
Hi Mani,
Please read this Community answer to understand the difference between a source and destination object.
In this instance the 'it' is an issue link between a story and a feature. You will need to determine if the Feature issue is the source or destination as you are trying to get the linked issue for the feature on the line you have mentioned.
Thanks
Johnson
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Manikanta,
You are probably looking for something like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.user.ApplicationUser
import groovy.transform.Field
@Field ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Issue issue = event.issue
if(issue.issueType.name == "Story" && issue.status.name == "In Progress"){
def features = getLinkedIssues(issue, "Feature of")
def inProgressActionId = 100
features.each {
tranistionIssue(it.sourceObject, inProgressActionId)
}
}else if(issue.issueType.name == "Story" && issue.status.name == "In Progress"){
def features = getLinkedIssues(issue, "Feature of")
def doneActionId = 200
features.each {
def storiesInFeature = getLinkedIssues(it.sourceObject, "Features")
def allInDoneStatus = true
storiesInFeature.each {
if(it.destinationObject.status.name != "Done"){
allInDoneStatus = false
}
}
if(allInDoneStatus){
tranistionIssue(it.sourceObject, doneActionId)
}
}
}
def getLinkedIssues(Issue issue, def linkType){
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
List<IssueLink> linkedIssue = issueLinkManager.getOutwardLinks(issue.id).findAll{ it.issueLinkType.inward == linkType}
return linkedIssue
}
def tranistionIssue(def issue, actionId){
def issueService = ComponentAccessor.getIssueService()
def transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId,new IssueInputParametersImpl())
if (transitionValidationResult.isValid()) {
def transitionResult = issueService.transition(currentUser, transitionValidationResult)
}
}
This code is not tested and you will have to play around with the variables and properties in the script, but all the concept that you need are there.
The script gets link issues, checks statuses and transitions issue.
Move it around to work for you.
Thanks
Johnson Howard
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.
Hi Manikanta,
Please don't expect this script to work by just copy and pasting it.
It will need to rewritten to fit your needs and work correctly. It was just to show all the concepts needed to get you started.
Thanks
Johnson Howard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.