blob: e0743d1da4df824639f4f211a096fb2337beccfd [file] [log] [blame]
chnyda124ca042017-08-03 16:40:51 +02001#!/usr/bin/env python
2
chnydad6f76352017-08-07 12:49:34 +02003try:
4 import jenkins
5 HAS_JENKINS = True
6except ImportError:
7 HAS_JENKINS = False
chnyda124ca042017-08-03 16:40:51 +02008import salt.config
9
10def main():
chnydad6f76352017-08-07 12:49:34 +020011 if not HAS_JENKINS:
12 return {}
13
chnyda124ca042017-08-03 16:40:51 +020014 output = { "jenkins_plugins" : {} }
15 opts = salt.config.minion_config('/etc/salt/minion')
16 user = opts['jenkins']['user']
17 password = opts['jenkins']['password']
18 url = opts['jenkins']['url']
19
20 server = jenkins.Jenkins(url, username=user, password=password)
21 plugins = server.get_plugins(depth=1)
22 for plugin_name, plugin_dict in plugins.iteritems():
23 output["jenkins_plugins"][plugin_name[0]] = {"version" : (plugin_dict["backupVersion"] or 0)}
24 return output