2016-11-24 2 views
1

私は、Jenkinsホスト6台とJenkinsホスト1台を100個近くのプラグインを使用しています。すべてのインスタンスに同じプラグインとそれぞれのバージョンがあることを確認します。インスタンス間にインストールされたJenkinsプラグインの比較

以下のcurlコマンドを使用して、特定のホストで使用されているプラ​​グインのリストを取得しようとしました。私たちは、すべてのホストでプラグインのバージョンを比較するためのユーティリティを開発しようとしており、運用ホスト上にプラグインがない場合は報告します。

curl 'https://<Jenkins url>/pluginManager/api/xml?depth=1&x‌​path=/*/*/shortName|‌​/*/*/version&wrapper‌​=plugins' | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \2\n/g' 

答えて

1

これは完全な解決策ではありませんが、Pythonライブラリを活用して、バージョンの非互換性や欠落しているプラ​​グインを比較することは間違いありません。

import xml.etree.ElementTree as ET 
import requests 
import sys 
from itertools import zip_longest 
import itertools 
from collections import OrderedDict 
import collections 
import csv 

url = sys.argv[1].strip() 
filename = sys.argv[2].strip() 

response = requests.get(url+'/pluginManager/api/xml?depth=1',stream=True) 
response.raw.decode_content = True 
tree = ET.parse(response.raw) 
root = tree.getroot() 
data = {} 
for plugin in root.findall('plugin'): 
    longName = plugin.find('longName').text 
    shortName = plugin.find('shortName').text 
    version = plugin.find('version').text 
    data[longName] = version 
    with open(filename, 'w') as f: 
     [f.write('{0},{1}\n'.format(key, value)) for key, value in data.items()] 

csv形式のプラグインのリストを提供します。

これは後で別のインスタンスと比較するために使用でき、これはすべて単一のPythonスクリプトで実現できます。

0

私たちは、シェルでこのようにそれを実行します。

java -jar jenkins-cli.jar -s <jenkins-url> list-plugins > <outputfile> 

その後、我々は違いを決定するために、別のホストのためにその出力で動作します。

関連する問題