/*
* Generates command to install all plugins on this server
* to a remote server whose name is passed in as a variable
* Helpful utility script for cloning the plugin environment of a server
* Author: Ioannis K. Moutsatsos
*/
import jenkins.model.*;
def destinationServer='jenkinsDestinationServer' //modify this for you destination server
def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()
def pluginMap=[:]
def installBuffer=new StringBuffer()
def url= jenkins.model.Jenkins.instance.getRootUrl()
plugins.each {
println "${it.getShortName()} \n\tversion ${it.getVersion()} \n\t${it.getLongName()}"
pluginMap["${it.getShortName()}"]="${it.getLongName()}-${it.getVersion()}"
}
pluginMap.sort().each{key,value->
// println "$key \n\t $value"
installBuffer.append(key)
installBuffer.append(' ')
}
println "java -jar jenkins-cli.jar -s http://${destinationServer}:8080/ install-plugin ${installBuffer}"