@ Restricted ( DoNotUse . class ) // WebOnly public HttpResponse doPlugins ( ) { Jenkins . getInstance ( ) . checkPermission ( Jenkins . ADMINISTER ) ; JSONArray response = new JSONArray ( ) ; Map < String , JSONObject > allPlugins = new HashMap <> ( ) ; for ( PluginWrapper plugin : plugins ) { JSONObject pluginInfo = new JSONObject ( ) ; pluginInfo . put ( "installed" , true ) ; pluginInfo . put ( "name" , plugin . getShortName ( ) ) ; pluginInfo . put ( "title" , plugin . getDisplayName ( ) ) ; pluginInfo . put ( "active" , plugin . isActive ( ) ) ; pluginInfo . put ( "enabled" , plugin . isEnabled ( ) ) ; pluginInfo . put ( "bundled" , plugin . isBundled ) ; pluginInfo . put ( "deleted" , plugin . isDeleted ( ) ) ; pluginInfo . put ( "downgradable" , plugin . isDowngradable ( ) ) ; pluginInfo . put ( "website" , plugin . getUrl ( ) ) ; List < Dependency > dependencies = plugin . getDependencies ( ) ; if ( dependencies != null && ! dependencies . isEmpty ( ) ) { Map < String , String > dependencyMap = new HashMap <> ( ) ; for ( Dependency dependency : dependencies ) { dependencyMap . put ( dependency . shortName , dependency . version ) ; } pluginInfo . put ( "dependencies" , dependencyMap ) ; } else { pluginInfo . put ( "dependencies" , Collections . emptyMap ( ) ) ; } response . add ( pluginInfo ) ; } for ( UpdateSite site : Jenkins . getActiveInstance ( ) . getUpdateCenter ( ) . getSiteList ( ) ) { for ( UpdateSite . Plugin plugin : site . getAvailables ( ) ) { JSONObject pluginInfo = allPlugins . get ( plugin . name ) ; if ( pluginInfo == null ) { pluginInfo = new JSONObject ( ) ; pluginInfo . put ( "installed" , false ) ; } pluginInfo . put ( "name" , plugin . name ) ; pluginInfo . put ( "title" , plugin . getDisplayName ( ) ) ; pluginInfo . put ( "excerpt" , plugin . excerpt ) ; pluginInfo . put ( "site" , site . getId ( ) ) ; pluginInfo . put ( "dependencies" , plugin . dependencies ) ; pluginInfo . put ( "website" , plugin . wiki ) ; response . add ( pluginInfo ) ; } } return hudson . util . HttpResponses . okJSON ( response ) ; }
Get the list of all plugins - available and installed .