Issue
-
I want to promote all plugins to the latest in a managed Update Center
-
I want to promote all plugins to the latest stored version in a managed Update Center
Environment
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Operations Center
-
CloudBees CI (CloudBees Core) on traditional platforms - Operations Center
-
CloudBees Jenkins Enterprise - Operations center
Resolution
The promotion of plugin version in a managed update center is manual. It is therefore cumbersome to promote a large number plugins.
The solution is to use a groovy script that you can execute from Manage Jenkins > Script Console.
Example 1: Bulk promote all stored plugins to the "Latest Version"
The following groovy script promotes all plugins currently stored in a managed updated center to "Latest Version". Whenever a more recent version is pulled, it will be promoted.
Replace the value myUpdateCenter by the full name of your update center.
|
import com.cloudbees.plugins.updatecenter.PluginData // Example of an update center "myUpdateCenter" at root level def updateCenterFullName = "myUpdateCenter" jenkins.model.Jenkins.instance.getItemByFullName("${updateCenterFullName}").getPluginsData().each { PluginData pluginData -> if(pluginData.getVersions() != null && !pluginData.getVersions().isEmpty()) { println "Promoting '${pluginData.getName()}' to latest (latestVersion: '${pluginData.getVersions().firstKey()}')" pluginData.setPromotedVersion(PluginData.LATEST_VERSION_STRING) } else { println "(Plugin '${pluginData.getName()}' is not pulled yet. Not promoting)" } } return
Example 2: Bulk promote all stored plugins to the current latest version
The following groovy script promotes all plugins currently stored in a managed updated center to the latest version in store:
Replace the value myUpdateCenter by the full name of your update center.
|
import com.cloudbees.plugins.updatecenter.PluginData // Example of an update center "myUpdateCenter" at root level def updateCenterFullName = "myUpdateCenter" jenkins.model.Jenkins.instance.getItemByFullName("${updateCenterFullName}").getPluginsData().each { PluginData pluginData -> if(pluginData.getVersions() != null && !pluginData.getVersions().isEmpty()) { println "Promoting '${pluginData.getName()}' to version '${pluginData.getVersions().lastKey()}'" pluginData.setPromotedVersion("${pluginData.getVersions().lastKey()}") } else { println "(Plugin '${pluginData.getName()}' is not pulled yet. Not promoting)" } }