how to programatically change a project's workflow in Jira

tommy guo
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2013

I'm trying to use the DefaultWorkFlowSchemeEditor

(reference: https://developer.atlassian.com/static/javadoc/jira/5.2.11/reference/com/atlassian/jira/projectconfig/workflow/DefaultWorkflowSchemeEditor.html)

to change the default workflow of created projects programatically. Can anyone please give me an example of how I can use the assign function to make the created project have a workflow of type "mycustomworkflow" instead of the default work flow assigned by Jira?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Colin Goudie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2013

Probably something like

workflowScheme = workflowSchemeManager.getScheme(ID);
project = projectManager.getProjectObjByKey("TST");
workflowSchemeManager.addSchemeToProject(project, workflowScheme);

Haven't tested that, but it may point you in the direction

tommy guo
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2013

Hey Colin, thank you for the reply. I'm just wondering will addSchemeToProject actually change the current workflow that the project is following?

tommy guo
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 26, 2013

I tested it out and it worked with a few modifications, thanks! =)

John Rassel February 24, 2014

Can you share your findings? I'm trying to accomplish a similiar thing with no luck:

https://answers.atlassian.com/questions/264805/create-a-workflow-programatically

Thanks

0 votes
Patrick Li
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2013

I am assuming those are new projects with no issues?

You can use SchemeManager, e.g. schemeManager.addSchemeToProject(project, scheme);

Or you can try using the WorkflowMigrationHelper,

WorkflowMigrationHelper migrationHelper = migrationHelperFactory.createMigrationHelper(getProject(), getScheme());
migrationHelper.doQuickMigrate();

tommy guo
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2013

Hey patrick I appreciate the reply. Would the addSchemeToProject function be capable of changing the current workflow that the project is following?

TAGS
AUG Leaders

Atlassian Community Events