Hi Christophe
I hope this is not too late and perhaps it might help others. The Futures
job returned from the deploy operation contains isDone() operation you can
use like so by registering in a map and checking
plugins.each {
logger.info("> checking " + it)
if (!pm.getPlugin(it)) {
logger.info("> looking updatecenter for " + it)
if (!initialized) {
uc.updateAllSites()
initialized = true
}
def plugin = uc.getPlugin(it)
if (plugin) {
logger.info("> installing " + it)
*futures[it] = plugin.deploy()*
installed = true;
}
}
}
*def allInstalled = false*
* while(!allInstalled){*
* def countOfDone = 0*
* futures.each{ k, v -> *
* if(v.isDone()){*
* countOfDone++*
* }*
* }*
* if(futures.size() == countOfDone){*
* allInstalled = true;*
* }else {*
* logger.info("> count of done " + countOfDone)*
* sleep(1000)*
* }*
* }*
inputFile.write("initialized")
logger.info("> plugins installed user created, initializing a restart!")
On Wednesday, November 9, 2016 at 11:23:48 AM UTC+13, [email protected]
wrote:
>
> Hi,
>
> I use a small groovy script to install automatically a set of plugins
> (including their dependencies):
> def pluginParameter="ldap matrix-auth ssh-credentials"
> def plugins = pluginParameter.split()
> def instance = Jenkins.getInstance()
> def pluginManager = instance.getPluginManager()
> def updateCenter = instance.getUpdateCenter()
> def installed = false
>
> plugins.each {
> if (!pluginManager.getPlugin(it)) {
> def plugin = updateCenter.getPlugin(it)
> if (plugin) {
> println("Installing " + it)
> def installationJob = plugin.deploy()
> installed = true
> }
> }
> }
>
> instance.save()
> if (installed)
> instance.doSafeRestart()
>
> I want to wait that plugins are effectively installed before proceeding
> with next instruction of the script. Plugin installation is an async task.
> I tried to use plugin.deploy.get() as deploy() returns a Future but the
> script ends before all plugins and dependencies are effectively installed.
> Is there a way to wait until plugins and dependencies are effectively
> installed?
>
> Regards,
> Christophe
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/5ce960bd-5c57-4cb8-8ba8-febe9766a3da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.