Issue
-
I want to promote a plugin and its dependencies in a managed Update Center
-
I want to store/download a plugin and its dependencies in a managed Update Center
-
I want to know what dependencies are required for a plugin in a managed Update Center
Resolution
As an alternative to using a custom update center, consider using Plugin management with CasC or Create an alternate plugin download site. |
The CloudBees Update Center Plugin provides the ability to host and manage custom Update Center(s). Plugins are advertised by a managed Update Center through 2 steps: Store and Promote. A limitation of these features is that the dependencies of a the plugin being stored or promoted are not automatically picked.
To workaround that problem, the following groovy script can be used: ucStoreAndPromoteWithDependencies.groovy
This groovy script is not supported by CloudBees engineering, it is shared here as a solution that CloudBees support has found to work with other CloudBees clients. |
The script calculate the dependencies required for a specific plugin name/version and execute an action: STORE, PROMOTE or NOOP (nothing). This can be controlled by the following variables:
-
pluginName
: The short name of the plugin (ex:'nectar-rbac'
) -
pluginVersion
: The version of the plugin or an empty string to pick up the latest (ex:'5.15'
) -
updateCenterFullName
: The full name of the update center item (ex:'RegionA/RegionAUpdateCenter'
) -
updateCenterAction
: The action to undertake:'STORE'
'PROMOTE'
'NOOP'
(default) -
updateCenterActionDryRun
: Whether to execute a dry run or no,true
by default
The output of the script depends on the state of the update center - which plugin already stored/promoted - and the upstream source - what plugins versions are available upstream. It also provide detailed logging for each operations. For more details and documentation, please have a look at the script.
Examples
In the following example, an Update Center with the following upstream source is used:

The advertised version of the nectar-rbac for that upstream source is 5.12
. We will show how to store/promote versions of the nectar-rbac
plugin with its dependencies.
Calculate a plugin required dependencies
I run the script to check what plugins are required to run the latest version of nectar-rbac
by specifying the following value:
-
def pluginName = 'nectar-rbac'
-
def pluginVersion = ''
-
def updateCenterFullName = 'RegionA/RegionAUpdateCenter'
-
def updateCenterAction = 'NOOP'
-
def updateCenterActionDryRun = true
The output tells me:
Required Dependencies ----------------- async-http-client:1.7.24.1 cloudbees-folder:5.13 cloudbees-license:9.3 nectar-license:8.3 nectar-rbac:5.12 variant:1.1
Store upstream version of a plugin with dependencies
The Update Center has the latest version nectar-rbac:5.12
stored but not the required dependencies. I run the script to store the latest version of nectar-rbac
with its dependencies by specifying the following value:
-
def pluginName = 'nectar-rbac'
-
def pluginVersion = ''
-
def updateCenterFullName = 'RegionA/RegionAUpdateCenter'
-
def updateCenterAction = 'STORE'
-
def updateCenterActionDryRun = false
The output shows that the plugin versions are being pulled:
Result ---------------------------------- Required Dependencies ----------------- async-http-client:1.7.24.1 cloudbees-folder:5.13 cloudbees-license:9.3 nectar-license:8.3 nectar-rbac:5.12 variant:1.1 ---------------------------------- Download required dependencies: ---------------------------------- [async-http-client:1.7.24.1] Pulling plugin version [cloudbees-folder:5.13] Pulling plugin version [cloudbees-license:9.3] Pulling plugin version [nectar-license:8.3] Pulling plugin version [nectar-rbac:5.12] Is already in store. [variant:1.1] Pulling plugin version
And I can see Jenkins is pulling the plugins versions:

Store specific version of a plugin with dependencies
When storing/promoting a specific version, the script tries to find the EXACT match. If it does not find it, it will search for a later version |
The Update Center has the latest version nectar-rbac:5.12
with its dependencies stored. I run the script to store the specific version nectar-rbac:5.13
with its dependencies by specifying the following value:
-
def pluginName = 'nectar-rbac'
-
def pluginVersion = '5.13'
-
def updateCenterFullName = 'RegionA/RegionAUpdateCenter'
-
def updateCenterAction = 'STORE'
-
def updateCenterActionDryRun = false
The output shows:
Calculate required dependencies: ---------------------------------- [nectar-rbac:5.15] Checking available versions in store... Does not have any suitable version in store Checking available versions for download... Does not have any suitable updates available for download [ERROR] No suitable version(s) found in store or for download ---------------------------------- Result ---------------------------------- !!! Found inconsistencies during the calculation of dependencies. Have a look at '[ERROR]' messages) !!!
That’s because this specific version of nectar-rbac
is not available in store and there is no exact match or more recent version in the upstream source.
In that case where you really need a specific version, you can upload nectar-rbac:5.13
manually in the update center and then re-run the script:
Result ---------------------------------- Required Dependencies ----------------- async-http-client:1.7.24.1 cloudbees-folder:5.13 cloudbees-license:9.3 nectar-license:8.3 nectar-rbac:5.15 variant:1.1 ---------------------------------- Download required dependencies: ---------------------------------- [async-http-client:1.7.24.1] Is already in store. [cloudbees-folder:5.13] Is already in store. [cloudbees-license:9.3] Is already in store. [nectar-license:8.3] Is already in store. [nectar-rbac:5.15] Is already in store. [variant:1.1] Is already in store.
Promote upstream version of a plugin with dependencies
The Update Center has the latest version nectar-rbac:5.12
with its dependencies stored for that upstream source but none is promoted. I run the script to promote the latest version of nectar-rbac
with its dependencies by specifying the following value:
-
def pluginName = 'nectar-rbac'
-
def pluginVersion = ''
-
def updateCenterFullName = 'RegionA/RegionAUpdateCenter'
-
def updateCenterAction = 'PROMOTE'
-
def updateCenterActionDryRun = false
The output shows that the plugin versions have been promoted:
Result ---------------------------------- Required Dependencies ----------------- async-http-client:1.7.24.1 cloudbees-folder:5.13 cloudbees-license:9.3 nectar-license:8.3 nectar-rbac:5.12 variant:1.1 ---------------------------------- Promote required dependencies: ---------------------------------- [async-http-client:1.7.24.1] Promoting plugin version [cloudbees-folder:5.13] Promoting plugin version [cloudbees-license:9.3] Promoting plugin version [nectar-license:8.3] Promoting plugin version [nectar-rbac:5.12] Promoting plugin version [variant:1.1] Promoting plugin version
And the update center shows the version is promoted as expected:

Promote specific version of a plugin with dependencies
When storing/promoting a specific version, the script tries to find the EXACT match. If it does not find it, it will search for a later version |
It has several versions of nectar-rbac
stored: 5.12
(promoted), 5.13
, 5.15
. I run the script to promote the specific version nectar-rbac:5.13
with its dependencies by specifying the following value:
-
def pluginName = 'nectar-rbac'
-
def pluginVersion = '5.13'
-
def updateCenterFullName = 'RegionA/RegionAUpdateCenter'
-
def updateCenterAction = 'PROMOTE'
-
def updateCenterActionDryRun = false
The output shows that the plugin versions have been promoted:
Result ---------------------------------- Required Dependencies ----------------- async-http-client:1.7.24.1 cloudbees-folder:5.13 cloudbees-license:9.3 nectar-license:8.3 nectar-rbac:5.13 variant:1.1 ---------------------------------- Promote required dependencies: ---------------------------------- [async-http-client:1.7.24.1] Is already promoted. [cloudbees-folder:5.13] Is already promoted. [cloudbees-license:9.3] Is already promoted. [nectar-license:8.3] Is already promoted. [nectar-rbac:5.13] Promoting plugin version [variant:1.1] Is already promoted.
And the update center shows the version is promoted as expected:

Going Further
Storing plugins versions requires Jenkins to perform tasks that are puts in the queue. For this reason, the script does not execute a "store and promote" in one go. Instead you need to run the script STORE
action first and when plugins downloads are completed rerun it with the PROMOTE
action. Another solution could be to promote the plugins to the latest version in store as shown in the promotePlugins method.