from jenkinsapi.jenkins import Jenkins
#get the server instance
jenkins_url = 'http://<jenkins-hostname>:<jenkins-port>/jenkins'
server = Jenkins(jenkins_url, username = '<user>', password = '<password>')
#get the installed plugins as list and print the pairs
plugins_dictionary = server.get_plugins().get_plugins_dict()
for key, value in plugins_dictionary.iteritems():
print "Plugin name: %s, version: %s" %(key, value.version)
if [ -f $JENKINS_HOME/plugin_versions.txt ]; then
rm $JENKINS_HOME/plugin_versions.txt
fi
for dir in $JENKINS_HOME/plugins/*/; do
dir=${dir%*/}
dir=${dir##*/}
version=$(grep Plugin-Version $JENKINS_HOME/plugins/$dir/META-INF/MANIFEST.MF | awk -F': ' '{print $2}')
echo $dir $version >> $JENKINS_HOME/plugin_versions.txt
done
# list of plugins in sorted order
# Copy this into your Jenkins script console
def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()
List<String> list = new ArrayList<String>()
i = 0
plugins.each {
++i
//println " ${i} ${it.getShortName()}: ${it.getVersion()}"
list.add("${it.getShortName()}: ${it.getVersion()}")
}
list.sort{it}
i = 0
for (String item : list) {
i++
println(" ${i} ${item}")
}