Java Code Examples for jenkins.model.Jenkins#getPluginManager()

The following examples show how to use jenkins.model.Jenkins#getPluginManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApplyStepExecution.java    From kubernetes-pipeline-plugin with Apache License 2.0 6 votes vote down vote up
protected Class<?> findPluginClass(String className) {
    try {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader == null) {
            classLoader = ClassLoader.getSystemClassLoader();
        }
        if (classLoader == null) {
            throw new ClassNotFoundException();
        }
        return classLoader.loadClass(className);
    } catch (ClassNotFoundException e) {
        Jenkins instance = Jenkins.getInstance();
        PluginManager pluginManager = instance.getPluginManager();
        try {
            return pluginManager.uberClassLoader.loadClass(className);
        } catch (ClassNotFoundException e1) {
            // ignore
        }
    }
    return null;
}
 
Example 2
Source File: Gitea.java    From gitea-plugin with MIT License 5 votes vote down vote up
public Gitea jenkinsPluginClassLoader() {
    // HACK for Jenkins
    // by rights this should be the context classloader, but Jenkins does not expose plugins on that
    // so we need instead to use the uberClassLoader as that will have the implementations
    Jenkins instance = Jenkins.getInstanceOrNull();
    classLoader = instance == null ? getClass().getClassLoader() : instance.getPluginManager().uberClassLoader;
    // END HACK
    return this;
}