Last active
January 8, 2018 15:49
-
-
Save sheehan/7e7e800d13092ef71684d8cd7254d6d2 to your computer and use it in GitHub Desktop.
Run this script in the Jenkins console to get the all the plugin dependencies for use with the Job DSL and Jenkins Test Harness..
This file contains 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
Jenkins.instance.pluginManager.activePlugins.sort { it.shortName }.each { plugin -> | |
def manifest = plugin.manifest | |
String groupId = manifest.mainAttributes.getValue('Group-Id') | |
String artifactId = manifest.mainAttributes.getValue('Extension-Name') | |
String version = manifest.mainAttributes.getValue('Implementation-Version') | |
if (groupId && artifactId && version) { | |
println "testPlugins '$groupId:$artifactId:$version'" | |
} | |
} |
This file contains 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
String pluginName = 'workflow-cps-global-lib' | |
def mainPlugin = Jenkins.instance.pluginManager.getPlugin(pluginName) | |
List pluginWithDependencies = [mainPlugin] | |
if (mainPlugin.hasDependencies()) { | |
pluginWithDependencies.addAll mainPlugin.dependencies.collect { Jenkins.instance.pluginManager.getPlugin it.shortName } | |
} | |
pluginWithDependencies.each { plugin -> | |
def manifest = plugin.manifest | |
String groupId = manifest.mainAttributes.getValue('Group-Id') | |
String artifactId = manifest.mainAttributes.getValue('Extension-Name') | |
String version = manifest.mainAttributes.getValue('Implementation-Version') | |
if (groupId && artifactId && version) { | |
println "testPlugins '$groupId:$artifactId:$version'" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment