Source:
private void trackInitialPluginInstall(@Nonnull final List<Future<UpdateCenter.UpdateCenterJob>> installJobs) { final Jenkins jenkins = Jenkins.getActiveInstance(); final UpdateCenter updateCenter = jenkins.getUpdateCenter(); updateCenter.persistInstallStatus(); if (jenkins.getInstallState() == InstallState.NEW) { jenkins.setInstallState(InstallState.INITIAL_PLUGINS_INSTALLING); new Thread() { @Override public void run() { final boolean failures[] = { false }; INSTALLING: while (true) { try { updateCenter.persistInstallStatus(); Thread.sleep(500); failures[0] = false; for (Future<UpdateCenter.UpdateCenterJob> jobFuture : installJobs) { if(!jobFuture.isDone() && !jobFuture.isCancelled()) { continue INSTALLING; } UpdateCenter.UpdateCenterJob job = jobFuture.get(); if(job instanceof InstallationJob && ((InstallationJob)job).status instanceof DownloadJob.Failure) { failures[0] = true; } } } catch (Exception e) { LOGGER.log(WARNING, "Unexpected error while waiting for initial plugin set to install.", e); } break; } updateCenter.persistInstallStatus(); if(!failures[0]) { jenkins.setInstallState(InstallState.INITIAL_PLUGINS_INSTALLING.getNextState()); } } }.start(); } new Thread() { @Override public void run() { INSTALLING: while (true) { for (Future<UpdateCenter.UpdateCenterJob> deployJob : installJobs) { try { Thread.sleep(500); } catch (InterruptedException e) { LOGGER.log(SEVERE, "Unexpected error while waiting for some plugins to install. Plugin Manager state may be invalid. Please restart Jenkins ASAP.", e); } if (!deployJob.isCancelled() && !deployJob.isDone()) { continue INSTALLING; } } resolveDependantPlugins(); break; } } }.start(); }

Target:
private void trackInitialPluginInstall(@Nonnull final List<Future<UpdateCenter.UpdateCenterJob>> installJobs) { final Jenkins jenkins = Jenkins.getActiveInstance(); final UpdateCenter updateCenter = jenkins.getUpdateCenter(); updateCenter.persistInstallStatus(); if (jenkins.getInstallState() == InstallState.NEW) { jenkins.setInstallState(InstallState.INITIAL_PLUGINS_INSTALLING); new Thread() { @Override public void run() { boolean failures = false; INSTALLING: while (true) { try { updateCenter.persistInstallStatus(); Thread.sleep(500); failures = false; for (Future<UpdateCenter.UpdateCenterJob> jobFuture : installJobs) { if(!jobFuture.isDone() && !jobFuture.isCancelled()) { continue INSTALLING; } UpdateCenter.UpdateCenterJob job = jobFuture.get(); if(job instanceof InstallationJob && ((InstallationJob)job).status instanceof DownloadJob.Failure) { failures = true; } } } catch (Exception e) { LOGGER.log(WARNING, "Unexpected error while waiting for initial plugin set to install.", e); } break; } updateCenter.persistInstallStatus(); if(!failures) { jenkins.setInstallState(InstallState.INITIAL_PLUGINS_INSTALLING.getNextState()); } } }.start(); } new Thread() { @Override public void run() { INSTALLING: while (true) { for (Future<UpdateCenter.UpdateCenterJob> deployJob : installJobs) { try { Thread.sleep(500); } catch (InterruptedException e) { LOGGER.log(SEVERE, "Unexpected error while waiting for some plugins to install. Plugin Manager state may be invalid. Please restart Jenkins ASAP.", e); } if (!deployJob.isCancelled() && !deployJob.isDone()) { continue INSTALLING; } } resolveDependantPlugins(); break; } } }.start(); }