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

This widget could not be displayed.

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.

This widget could not be displayed.

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;
}

Code is not able to understand 

MigrationHelperFactory 

Can you provide me the import statement?

Thanks,

Chandan 

Here is a link of API documentation:
https://docs.atlassian.com/software/jira/docs/api/7.2.3/com/atlassian/jira/workflow/migration/MigrationHelperFactory.html

You need to import it like this:

import com.atlassian.jira.workflow.migration.MigrationHelperFactory;

 I highly recommend IDE that does this more or less for you (I use IntelliJ Idea)

Thanks Peter. But I am using Jira-api-7.7.1.jar which do not contain this package. 

I am wondering why they have skipped it?

I think issue is not with version, but I am not able to see this package in any of the version i downloaded.

This is what I have in pom.xml

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>

Do I need to add something more.

You need also:

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>

 

Note the jira-core artifactId.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

82 views 0 1
Join discussion

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