chnyda | 124ca04 | 2017-08-03 16:40:51 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
chnyda | d6f7635 | 2017-08-07 12:49:34 +0200 | [diff] [blame] | 3 | try: |
| 4 | import jenkins |
| 5 | HAS_JENKINS = True |
| 6 | except ImportError: |
| 7 | HAS_JENKINS = False |
chnyda | 124ca04 | 2017-08-03 16:40:51 +0200 | [diff] [blame] | 8 | import salt.config |
| 9 | |
| 10 | def main(): |
chnyda | d6f7635 | 2017-08-07 12:49:34 +0200 | [diff] [blame] | 11 | if not HAS_JENKINS: |
| 12 | return {} |
| 13 | |
chnyda | 124ca04 | 2017-08-03 16:40:51 +0200 | [diff] [blame] | 14 | 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(): |
chnyda | 9c05a3d | 2017-08-07 22:37:25 +0200 | [diff] [blame^] | 23 | output["jenkins_plugins"][plugin_name[0]] = {"version" : (plugin_dict["version"] or 0)} |
chnyda | 124ca04 | 2017-08-03 16:40:51 +0200 | [diff] [blame] | 24 | return output |