Guest User

Untitled

a guest
Nov 8th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. - name: Compare plugins
  2. hosts: jenkins[0]
  3. gather_facts: false
  4. #connection: local
  5. tasks:
  6. - name: Load active plugins list from Jenkins
  7. jenkins_script:
  8. script: |
  9. import groovy.json.JsonOutput
  10. def plugins = []
  11. jenkins.model.Jenkins.instance.getPluginManager().getPlugins().each{
  12. plug = [:]
  13. plug.put('name', it.getShortName())
  14. plug.put('version', it.getVersion().split(' ')[0])
  15. plugins.add(plug)
  16. }
  17. println(JsonOutput.toJson(plugins.sort{a,b -> a.name <=> b.name}))
  18. url: "{{ jenkins_instance_url }}"
  19. user: "{{ jenkins_ext_admin_username }}"
  20. password: "{{ jenkins_ext_admin_password }}"
  21. timeout: "{{ jenkins_script_timeout }}"
  22. register: active_plugins_list
  23.  
  24. - name: Get plugins diffirence
  25. assert:
  26. that: "(jenkins_plugins | json_query('[?state != `disabled`]') | sort | difference(active_plugins_list.output | from_json | sort) | length) == 0"
  27. msg: "Found different versions of Jenkins plugins:\n{{ jenkins_plugins | json_query('[?state != `disabled`]') | sort | difference(active_plugins_list.output | from_json | sort) | to_yaml }}"
Add Comment
Please, Sign In to add comment