Capturing plugin installation/uninstallation events
We have seen plugins that are great in terms of functionality but come with a big list of configuration steps. Its much like a treadmill; a great asset but very hard to assemble!
Is there a way we can handle these configurations automatically (like creating custom fields, adding options, creating listeners, services, and so on), when the plugin is installed? The answer is "Yes".
How to do it…
It is simple. Really! Let us look at creating a custom field automatically during a plugin installation and deleting it while uninstalling. The same logic applies as for the enabling/disabling of the plugin. All you need to do is two simple steps:
Write an event listener. We will use the
atlassian-event
library here.Implement the Spring interfaces
InitializingBean
andDisposableBean
to capture the plugin lifecycle events.
Writing an event listener in JIRA is quite easy. Just perform the following steps:
Import the
EventPublisher
instance used to register...