@ RequirePOST @ Restricted ( DoNotUse . class ) // WebOnly public HttpResponse doInstallPlugins ( StaplerRequest req ) throws IOException { Jenkins . getInstance ( ) . checkPermission ( Jenkins . ADMINISTER ) ; String payload = IOUtils . toString ( req . getInputStream ( ) , req . getCharacterEncoding ( ) ) ; JSONObject request = JSONObject . fromObject ( payload ) ; JSONArray pluginListJSON = request . getJSONArray ( "plugins" ) ; List < String > plugins = new ArrayList <> ( ) ; for ( int i = 0 ; i < pluginListJSON . size ( ) ; i ++ ) { plugins . add ( pluginListJSON . getString ( i ) ) ; } UUID correlationId = UUID . randomUUID ( ) ; try { boolean dynamicLoad = request . getBoolean ( "dynamicLoad" ) ; install ( plugins , dynamicLoad , correlationId ) ; JSONObject responseData = new JSONObject ( ) ; responseData . put ( "correlationId" , correlationId . toString ( ) ) ; return hudson . util . HttpResponses . okJSON ( responseData ) ; } catch ( Exception e ) { return hudson . util . HttpResponses . errorJSON ( e . getMessage ( ) ) ; } }
Installs a list of plugins from a JSON POST .