I have 6 Jenkins hosts and one production Jenkins hosts where we are using close to 100 plugins. We want to make sure that all the instances have same plugins and their respective versions.
We tried below curl command to retrieve list of plugins used by particular host. We are trying to develop the utility to compare the plugin versions across all the hosts and give us report if any plugin is missing on production host.
curl 'https://<Jenkins url>/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins' | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \2\n/g'
This is not a complete solution but you can definitely leverage Python libraries in order to compare the version incompatibilities OR missing plugins.
import xml.etree.ElementTree as ET import requests response = requests.get('<Jenkins URL>',stream=True) #print (response.content) response.raw.decode_content = True tree = ET.parse(response.raw) root = tree.getroot() for plugin in root.findall('plugin'): longName = plugin.find('longName').text shortName = plugin.find('shortName').text version = plugin.find('version').text print (longName, version)
Will give you the list of plugins
Jenkins Translation Assistance plugin 1.10 Jenkins Workspace Cleanup Plugin 0.26 Hudson global-build-stats plugin 1.4 conditional-buildstep 1.3.3 Jenkins GIT plugin 2.4.0 PMD Plug-in 3.41 Matrix Project Plugin 1.4.1 External Monitor Job Type Plugin 1.4
Which later can be used to compare with another instance and all this can be achieved in a single python script.