Skip to content

Instantly share code, notes, and snippets.

@jetersen
Last active November 6, 2019 06:24
Show Gist options
  • Save jetersen/f2034d3d8d8cd61a99a08a2f48c49d23 to your computer and use it in GitHub Desktop.
Save jetersen/f2034d3d8d8cd61a99a08a2f48c49d23 to your computer and use it in GitHub Desktop.
Produces a Jenkins plugins.txt with the updated versions of plugins.
//this will produce dependencies xml to be put into a dependencies block inside a pom.xml with the updated plugin version.
def plugins = Jenkins.instance.pluginManager.plugins.toSorted()
plugins.each { plugin ->
def attrs = plugin.getManifest().mainAttributes
def update = plugin.updateInfo
def version = "${plugin.version}"
if (update != null) {
version = "${update.version}"
println "<!-- Upgraded ${plugin.shortName} from ${plugin.version} to ${update.version} -->"
}
println "<dependency>"
println " <groupId>${attrs.getValue('Group-Id')}</groupId>"
println " <artifactId>${plugin.shortName}</artifactId>"
println " <version>${version}</version>"
println "</dependency>"
println ""
}
//this will produce plugins.txt with the updated plugin version.
def plugins = Jenkins.instance.pluginManager.plugins.toSorted()
plugins.each { plugin ->
def update = plugin.updateInfo
def version = "${plugin.version}"
if (update != null) {
version = "${update.version}"
println "# Upgraded ${plugin.shortName} from ${plugin.version} to ${update.version}"
}
println "${plugin.shortName}:${version}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment