Trigger methods after plugin is enabled


I am developing a Jira plugin and I would like to trigger the creation of custom fields right after the enabling of said plugin.

How would you recommend to do this?

I came across this old topic, but the mechanism it describes seems to be deprecated.

I also took a look at this:, but I’m not sure how to adapt it to my problem.

For now, I am using a component that implements InitializingBean, and adding things to this method, but it doesn’t feel right…

     * Called when the plugin has been enabled.
     * @throws Exception
    public void afterPropertiesSet() throws Exception {"Enabling plugin");
        //Here createCustomFields();

Many thanks in advance!

Hello, @lorie.den-os.

I’ll break down my answer into two parts:

  1. Custom field creation on enable -
    Is there a specific reason why you need to wait for a specific event prior to custom field creation? I am thinking a server app that creates custom field already do this i.e. the custom field will be created only upon enabling the server app, and removes the custom field on disable (or uninstall). If you like to get your hands dirty in order to better understand (like me), kindly check this Creating a custom field tutorial.

  2. Trigger method after server app is enabled -
    I think you’ll be interested in the Jira plugin lifecycle, specifically PluginEnabledEvent which is discussed here.

Hope this helps.

1 Like

Thanks a lot for the quick response!

The first part of your answer is not exactly what I’m looking for: I don’t want to add a new custom field type, I want to instantiate automatically a list of custom fields of pre-existing types (so the user doesn’t have to do it manually). I want this process to be invisible.

I will most definitely look into the second part though :slight_smile: I might have more questions then!

Thanks again!

1 Like