JIRA project template - How to link to existing workflow?

I created a project template plugin, according to the tutorial here:

https://developer.atlassian.com/display/JIRADEV/Creating+a+Project+Template

It works fine.

But I try to avoid creating always a new workflow scheme, new issue type scheme and etc.
How to use existing ones? Removing <add-project> in <project-blueprint> is not the solution, because I don't any other element, which I can use to link to existing stuff.

Any hint would be appreciated.

And where to find the API description of: com.atlassian.jira.blueprint.api ??

2 answers

1 accepted

I got the following information from an atlassian member:

unfortunately Project Templates is designed to create new issue type and workflow schemes on each project creation and it is not possible through the JSON file to reuse an existing one. You can however use existing issue types by using the same name in the JSON configuration file. For example, if 'Bug' exists and you specify an issue type with name 'Bug' it will use the existing one in the system.

If there would really be a need to reuse existing schemes, you might try doing this through the AddProjectHook: don't specify a JSON configuration file and just do the creation/reusing of the schemes in that hook programatically.

Nice Idea, a hint to a code snipped would be nice ,-)

Hi Fred, the only chance is to change it programatically, see here: https://answers.atlassian.com/questions/279944/change-issue-type-scheme-programatically I hope Atlassian will update the blueprint interface, because right now it is not usable.

Here is a snippet of code that gives you a start:

@Override
public ConfigureResponse configure(final ConfigureData configureData) {
ConfigureResponse configureResponse = ConfigureResponse.create();

// Obviously you need to change the logic and add some null pointer protection. but it gives you an idea
WorkflowSchemeManager workflowSchemeManager = ComponentAccessor.getWorkflowSchemeManager();
Project project = configureData.project();
AssignableWorkflowScheme workflowScheme = workflowSchemeManager.getWorkflowSchemeObj(10100l);

MigrationHelperFactory migrationHelperFactory = ComponentAccessor.getComponent(DefaultMigrationHelperFactory.class);

try {
AssignableWorkflowSchemeMigrationHelper workflowSchemeMigrationHelper = migrationHelperFactory.createMigrationHelper(project,workflowScheme);
workflowSchemeMigrationHelper.doQuickMigrate();
} catch (GenericEntityException e) {
e.printStackTrace();
}

return configureResponse;
}

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

184 views 1 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you