Skip to content

Instantly share code, notes, and snippets.

@sheehan
Last active January 8, 2018 15:49
Show Gist options
  • Save sheehan/7e7e800d13092ef71684d8cd7254d6d2 to your computer and use it in GitHub Desktop.
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..
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'"
}
}
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