func (p *Plugin) OnConfigurationChange() error {
	var configuration = new(configuration)
	if err := p.API.LoadPluginConfiguration(configuration); err != nil {
		return errors.Wrap(err, "failed to load plugin configuration")
	}
	serverConfiguration := p.API.GetConfig()
	p.setConfiguration(configuration, serverConfiguration)
	return nil
}
OnConfigurationChange is invoked when configuration changes may have been made.
package main
import (
	"path"
	"reflect"
	"github.com/mattermost/mattermost-server/v5/model"
	"github.com/pkg/errors"
)
type configuration struct {
	JenkinsURL       string
	Username         string
	EncryptionKey    string
	ProfileImageURL  string
	PluginsDirectory string
}
func (c *configuration) Clone() *configuration {
	var clone = *c
	return &clone
}
func (p *Plugin) getConfiguration() *configuration {
	p.configurationLock.RLock()
	defer p.configurationLock.RUnlock()
	if p.configuration == nil {
		return &configuration{}
	}
	return p.configuration
}
func (p *Plugin) setConfiguration(configuration *configuration, serverConfiguration *model.Config) {
	p.configurationLock.Lock()
	defer p.configurationLock.Unlock()
	if configuration != nil && p.configuration == configuration {
		if reflect.ValueOf(*configuration).NumField() == 0 {
			return
		}
		panic("setConfiguration called with the existing configuration")
	}
	if serverConfiguration.PluginSettings.Directory != nil {
		configuration.PluginsDirectory = *serverConfiguration.PluginSettings.Directory
	}
	if serverConfiguration.ServiceSettings.SiteURL != nil {
		configuration.ProfileImageURL = path.Join("/plugins", manifest.ID, "assets", "jenkins.png")
	}
	p.configuration = configuration
}