Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to create a custom issue type in jira 7 plugin

SKR March 18, 2018

I am working on creating a custom issue type in my plugin unable to get it work even after following the tutorials.

Here is the code

 

package mycomp;

import mycomp.MyPluginComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.atlassian.jira.config.IssueTypeManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.config.properties.ApplicationProperties;
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import javax.inject.Inject;
import javax.inject.Named;

@Scanned
public class MyPluginComponentImpl implements MyPluginComponent{
private static final Logger log = LoggerFactory.getLogger(MyPluginComponentImpl.class);

@ComponentImport
private final ApplicationProperties applicationProperties;

@ComponentImport
private final IssueTypeManager itm;

@Inject
public MyPluginComponentImpl(ApplicationProperties applicationProperties, IssueTypeManager itm) {
this.applicationProperties = applicationProperties;
this.itm = itm;
createIssueType();
}

public String getName() {
return "testcomp";
}

public void createIssueType(){
itm.createIssueType("testcomp","Test",0l);
}

}

1 answer

0 votes
Alexey Matveev
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.
March 19, 2018

What is the error?

SKR March 19, 2018

First time I ran the command atlas-run I could see the issue type, later after some correction, it has vanished. No error or stack trace.

Alexey Matveev
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.
March 19, 2018

run atlas-debug. Set breakpoint to createIssueType() and have a look. But I think the right was is to implement the InitializingBean interface and create the issue type in the afterPropertiesSet method.

https://community.atlassian.com/t5/Marketplace-Apps-questions/Jira-plugin-quot-afterPropertiesSet-quot-and-quot-destroy-quot/qaq-p/97321

SKR March 19, 2018

I tried this code, still not clear what to implement in destroy()

 

still no luck......

 

 

package mycomp;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import com.atlassian.jira.extension.JiraStartedEvent;
import com.atlassian.event.api.EventListener;
import com.atlassian.event.api.EventPublisher;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.type.EventType;
import com.atlassian.jira.issue.Issue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.atlassian.jira.config.IssueTypeManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.config.properties.ApplicationProperties;

public class IssueCreatedResolvedListener implements InitializingBean, DisposableBean{
private static final Logger log = LoggerFactory.getLogger(IssueCreatedResolvedListener.class);
private final IssueTypeManager issueTypeManager ;
private final ApplicationProperties applicationProperties ;

public IssueCreatedResolvedListener(ApplicationProperties applicationProperties, IssueTypeManager issueTypeManager) {
this.applicationProperties = applicationProperties;
this.issueTypeManager = issueTypeManager;
}

@Override
public void afterPropertiesSet() throws Exception {
issueTypeManager.createIssueType("issueType", "issueType", "https://jira.atlassian.com/images/atlassian-jira-logo-large.png");
}

@Override
public void destroy() throws Exception {

}

}

Alexey Matveev
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.
March 19, 2018

If you are not sure, then do not implement anything. 

SKR March 19, 2018

Can you help me to fix this, as I am new to JIRA plugin dev?

Alexey Matveev
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.
March 19, 2018

Unfortunately I do not have time right now. You should learn how to debug your code. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events