Forked from alecharp/keep-jenkins-plugins-uptodate.groovy
Last active
April 3, 2022 05:35
-
-
Save cmaggiulli/fa981d6cb13462c3a10c11fb8847cdfa to your computer and use it in GitHub Desktop.
Simple groovy script to upgrade active plugins when new versions are available ( without warnings )
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.model.Jenkins.getInstance().getUpdateCenter().getSites().findAll{ !it.data.warnings }.each { site -> | |
site.updateDirectlyNow(hudson.model.DownloadService.signatureCheck) | |
} | |
hudson.model.DownloadService.Downloadable.all().each { downloadable -> | |
downloadable.updateNow(); | |
} | |
def plugins = jenkins.model.Jenkins.instance.pluginManager.activePlugins.findAll { | |
it -> it.hasUpdate() | |
}.collect { | |
it -> it.getShortName() | |
} | |
println "Plugins to upgrade: ${plugins}" | |
long count = 0 | |
jenkins.model.Jenkins.instance.pluginManager.install(plugins, false).each { f -> | |
f.get() | |
println "${++count}/${plugins.size()}.." | |
} | |
if(plugins.size() != 0 && count == plugins.size()) { | |
jenkins.model.Jenkins.instance.safeRestart() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment