Im currently trying to create custom issue types on addon installation, is there any way i can listen to events like in the jira server (life cycle events).Im writing the plugin using Spring boot connect app framework.
@DonPereraYou can do that. Here is brief idea,
"lifecycle": {
"installed": "/installed"
}
Can you post a sample method signature for the particular , i tried with admin scope but it goes and hits on the following
Mapped to public org.springframework.http.ResponseEntity<java.lang.Void> com.atlassian.connect.spring.internal.lifecycle.LifecycleController.installed(com.atlassian.connect.spring.internal.lifecycle.LifecycleEvent,com.atlassian.connect.spring.AtlassianHostUser)
not to the endpoint i defined.
Thanks!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@DonPerera Two things,
If you are not familiar with listening to custom events in Sprint framework, checkout this,
Your sample method code will look like this,
@EventListener
public void processAddonInstalledEvent(AddonInstalledEvent event) {
//Do event processing here
}
make sure you put this method in a bean.
Happy coding!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@DPKJ Thank you very much.
Works like a charm.
@Component
public class EventManager {
@EventListener
public void processAddonInstalledEvent(AddonInstalledEvent event) {
//logic
}
@EventListener
public void processAddonUninstalledEvent(AddonUninstalledEvent event) {
//logic
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Im able hit the Event Listener but when i send the rest call to create the issue type i get unauthorized exception.I already have the admin privileges.
atlassianHostRestClients.authenticatedAsAddon(host).postForObject("/rest/api/3/issuetype", dataObj, Boolean.class);
I have added the following scope to the descriptor as well,
"READ", "WRITE", "ACT_AS_USER","ADMIN"
but unable to create the issue type.How can i authenticate the request.
Thanks !!!!.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@DonPerera Have you tried removing addon and reinstalling it with fresh DB?
If not please try this.
Also take a look at this question, it have some related info - https://community.atlassian.com/t5/Answers-Developer-Questions/Cannot-set-avatar-for-issue-type-using-REST-API-with-JWT/qaq-p/568931
If all these things doesn't work do let me know, I will try this out on my sample site, and will get back to you. Or you can open another question for this :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was able to make it work. The problem had been the plugin needed to finish installing inoder to create the issue types,
Map<String, String> dataObj = new HashMap<>();
dataObj.put("name", "");
dataObj.put("description", "");
dataObj.put("type", "standard");
Executor.executorService.schedule(() -> {
String object = atlassianHostRestClients.authenticatedAsAddon(event.getHost()).postForObject("/rest/api/3/issuetype", dataObj, String.class);
assert object != null;
LOGGER.info("IssueType Created ".concat(object));
}, 15, TimeUnit.SECONDS);
So i put the issue type creation in to schedule thread to run after 15s.
Thanks!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nice work @DonPerera
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.