Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Workflow transition assignee by project admins

Hubert Sękowski October 15, 2019

I found this functionality extremely anticipated for my teams. I hope it helps you too :)

Firstly: what was the issue?

1) Needed flexibility with setting assignees when issues are moved to following statuses.

2) Assignees should be project specific.

3) Project administrators should be able to change the assignees.

What you need?

Two Jira plugins: ScriptRunner and Enhenced Project Properties

I do recommend to load following script to Jira server as it will be commonly used:

/***********************************************************************************/

import org.apache.log4j.Logger
import org.apache.log4j.Level
Logger log = Logger.getLogger("workflowTransitionAssignee.groovy")
log.setLevel(Level.DEBUG)

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser

String transientName = transientVars.getAt("descriptor").getAction(transientVars['actionId']).name
String propertyKey = "workflow.transition."+transientName+".assignee"

def pluginAccessor = ComponentAccessor.getPluginAccessor()
def projectPropertiesManager = null
try{
projectPropertiesManager = ComponentAccessor.getOSGiComponentInstanceOfType(pluginAccessor
.getClassLoader().findClass("com.tse.jira.projectproperties.plugin.api.ProjectPropertiesAOMgr"))
}catch(Exception e){
log.error("Enhanced Project Properties plugin (https://marketplace.atlassian.com/apps/1217709/enhanced-project-properties) not found in the instance")
return
}

def propertyComponent = projectPropertiesManager.getProjectPropertyByKey(issue.projectObject, propertyKey)
if(propertyComponent == null){
log.debug(propertyKey + " property key not found")
return
}else if(propertyComponent.propertyValue == null || propertyComponent.propertyValue.trim() == ""){
log.info("Value for property key "+propertyKey+" is null or empty")
return
}else{
log.debug("Property for " + propertyKey + " : " + propertyComponent.propertyValue)
}

ApplicationUser user = ComponentAccessor.userManager.getUserByName(propertyComponent.propertyValue)
if(user == null){
log.warn("User " + propertyComponent.propertyValue + " not found in the system")
return
}

issue.assignee = user

/***********************************************************************************/

Add the script to each transition where you want to have the functionality available. Remember the transition name!

Set project properties like:

workflow.transition.Create.assignee = dave
workflow.transition.In Progres.assignee = hubert

You can also modify Project Permissions scheme so Administrators can manage Project Properties and it's visible to Developers.

Disadvantage:

Project administrators have to use user names.

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events