jenkinsの最新バージョンを取得するURL https://stackoverflow.com/questions/43857882/how-to-query-the-current-jenkins-lts-version-number

Simple groovy script to upgrade active plugins when new versions are available jenkins safe auto update plugins

def jenkins = Jenkins.get()
UpdateCenter uc = jenkins.getUpdateCenter()
 
// UpdateSitesのデータ更新
uc.sites.each { site ->
    site.updateDirectlyNow()
}
 
def plugins = jenkins.pluginManager.activePlugins.collect {
    // 新しいバージョン
    UpdateSite.Plugin updateSitePlugin = uc.getPlugin(it.shortName, it.versionNumber)
    return [
            name             : it.shortName,
            installed_version: it.version as String,
            available_version: updateSitePlugin.version as String,
    ]
}
 
println plugins.collect { "${it.name}:${it.available_version}" }.join(" ")