how to use groovy code to change the workflow scheme for a JIRA project?
The WorkflowSchemeManager doesn't provide a method to remove or add workflow scheme from JIRA project
WorkflowSchemeManager extends SchemeManager. You have a addSchemeToProject() method.
Hello,
Suppose, you want to set workflow scheme from the template project to another project. The code would be something like that:
Project project = ComponentAccessor.getProjectManager().getProjectObjByKey("projectKey");Project templateProject = ComponentAccessor.getProjectManager().getProjectObjByKey("projectKey");ComponentAccessor.getWorkflowSchemeManager().addSchemeToProject(project, ComponentAccessor.getWorkflowSchemeManager().getSchemeFor(templateProject));
hi Alex,
I want to copy a workflow scheme from a template project and assign that copied workflow scheme to a new project. i tried your code, but it doesn't work. It remove the workflow scheme from both template and target project. When i go to admin page edit the template workflow scheme, the log shows the error below.
2017-11-21 04:04:51,206 http-nio-8080-exec-21 ERROR admin 244x10835x1 wllipk 10.209.96.235 /rest/globalconfig/latest/workflowschemeeditor/11401 [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: Passed List had more than one value.java.lang.IllegalArgumentException: Passed List had more than one value.at org.ofbiz.core.entity.EntityUtil.getOnly(EntityUtil.java:62)at com.atlassian.jira.workflow.DefaultWorkflowSchemeManager.getSchemeForProject(DefaultWorkflowSchemeManager.java:364)at com.atlassian.jira.workflow.DefaultWorkflowSchemeManager.getSchemeForProject(DefaultWorkflowSchemeManager.java:358)at com.atlassian.jira.workflow.DefaultWorkflowSchemeManager.getWorkflowMap(DefaultWorkflowSchemeManager.java:315)at sun.reflect.GeneratedMethodAccessor934.invoke(Unknown Source)... 1 filtered
,
Regards
I had the same issue. You have to remove the current workflow scheme first (because the function name is "add..." and there shall only be one ;-)).
workflowSchemeManager.removeSchemesFromProject(project)
Result for me was that the scheme was changed properly according to the project settings page but the tickets have not been migrated to the new workflow. They still follow the old scheme.
Does anyone have a idea how to trigger this process?
I had the same problem and just found a solution.
You have to migrate your issues before you remove the schemes from the project.
Here a code extract sample i made
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)def searchProvider = ComponentAccessor.getComponent(SearchProvider)def query = jqlQueryParser.parseQuery("project = AAA")def results = searchProvider.search(query, currentUser, PagerFilter.getUnlimitedFilter())def issueManager = ComponentAccessor.getIssueManager()results.getIssues().each() {documentIssue ->def issue = issueManager.getIssueObject(documentIssue.id)workflowManager.migrateIssueToWorkflow(issue, newWorkflow, issue.getStatus())}
Hi @Alexey Matveev , have you found a way to set the default workflow in the cloned workflowScheme for unassigned issue types in Jira 10.XX? Any guidance would be greatly appreciated. Thanks!
It looks like you're new here. Sign in or register to get started.