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 ??
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 ,-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Code is not able to understand
MigrationHelperFactory
Can you provide me the import statement?
Thanks,
Chandan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @IBL Software Engineering,
Your suggested code still creates new Workflow scheme and new Workflow for newly created project.
You have hardcode an id in the following code:
AssignableWorkflowScheme workflowScheme = workflowSchemeManager.getWorkflowSchemeObj(10100l);
Is this id of existing scheme?
I tried the following but didnt work:
ConfigureResponse configureResponse = ConfigureResponse.create();
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
Collection<JiraWorkflow> workflows = workflowManager.getWorkflows();
JiraWorkflow myWorkflow = null;
for (JiraWorkflow workflow : workflows) {
if (workflow.getName().indexOf("My Workflow") != -1) {
myWorkflow = workflow;
break;
}
}
if (myWorkflow != null) {
WorkflowSchemeManager workflowSchemeManager = ComponentAccessor.getWorkflowSchemeManager();
Project project = configureData.project();
AssignableWorkflowScheme workflowScheme;
try {
workflowScheme = (AssignableWorkflowScheme) workflowSchemeManager
.getWorkflowScheme(workflowSchemeManager.getSchemesForWorkflow(myWorkflow).iterator().next());
MigrationHelperFactory migrationHelperFactory = ComponentAccessor.getComponent(DefaultMigrationHelperFactory.class);
AssignableWorkflowSchemeMigrationHelper workflowSchemeMigrationHelper = migrationHelperFactory
.createMigrationHelper(project, workflowScheme);
workflowSchemeMigrationHelper.doQuickMigrate();
} catch (GenericEntityException e) {
e.printStackTrace();
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, 10100l is hardcoded workflow scheme object id (that is why I said that the code needs to be adjusted in the code comments). Add logs to figure out what is missing/wrong.
Did it find the workflow? Did it find the workflow scheme?
Are there any null pointers? Where any exceptions caught?
Add following to add logging functionality:
Logger log = LoggerFactory.getLogger(YouClass.class);
log.info("Workflow Scheme found : " + String.valueOf(workflowScheme));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.