Can someone help with the groovy script to conditionally create a sub-task when a Story moves from one project to another? I looking to use ScriptRunner Move Listener for this.
Use Case: When a Story moves out of/from the project key "CAP" to any other project, check if sub-task (Code Review) has been created and if not, create sub-task (Code Review) which is just a standard sub-task with "Code Review" as its summary. We need to also consider if a Story is moving into project key "CAP", do not create sub-task (Code Review).
Appreciating your help and please let me know if additional details are needed.
Thanks!
With scriptrunner's script listener, you can use the built-in "create subtask" listener and configure it as follows:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
Issue eventIssue = issue
def projectsList = projects
def sourceProject
def newProject
if(projectsList[0] == eventIssue.getProjectObject().getKey()){
sourceProject = projectsList[1]
newProject = projectsList[0]
}
else{
sourceProject = projectsList[0]
newProject = projectsList[1]
}
log.info("Issue moved from ${sourceProject} to ${newProject}")
def subtasks = eventIssue.getSubTaskObjects()
def subTaskExists = subtasks.any {it.getSummary().toLowerCase().contains("code review")}
if(sourceProject == "CAP" && !subTaskExists)
{
return true
}
else {
return false
}
You can probably simplify it/clean it up.
All the rest, I left empty.
Hope this helps
Kind regards
Jorden
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.