Last active
November 9, 2018 07:09
-
-
Save vadikgo/6297e6a91bcc398a05c33a5ae37d0e59 to your computer and use it in GitHub Desktop.
Compare jenkins plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Compare plugins | |
hosts: jenkins[0] | |
gather_facts: false | |
#connection: local | |
tasks: | |
- name: Load active plugins list from Jenkins | |
jenkins_script: | |
script: | | |
import groovy.json.JsonOutput | |
def plugins = [] | |
jenkins.model.Jenkins.instance.getPluginManager().getPlugins().each{ | |
plugins.add([name:it.getShortName(), version:it.getVersion().split(' ')[0]]) | |
} | |
println(JsonOutput.toJson(plugins.sort{a,b -> a.name <=> b.name})) | |
url: "{{ jenkins_instance_url }}" | |
user: "{{ jenkins_ext_admin_username }}" | |
password: "{{ jenkins_ext_admin_password }}" | |
timeout: "{{ jenkins_script_timeout }}" | |
register: active_plugins_list | |
- name: Get plugins diffirence | |
assert: | |
that: "(jenkins_plugins | json_query('[?state != `disabled`]') | sort | difference(active_plugins_list.output | from_json | sort) | length) == 0" | |
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 }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment