Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorten startup error #8

Merged
merged 1 commit into from
Sep 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@
package io.fabric8.jenkins.openshiftsync;

import hudson.Extension;
import io.fabric8.kubernetes.client.KubernetesClientException;
import jenkins.model.GlobalConfiguration;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;

import java.util.concurrent.Callable;
import java.util.logging.Level;
import java.util.logging.Logger;

import static io.fabric8.jenkins.openshiftsync.OpenShiftUtils.getNamespaceOrUseDefault;
import static io.fabric8.jenkins.openshiftsync.OpenShiftUtils.getOpenShiftClient;

@Extension
public class GlobalPluginConfiguration extends GlobalConfiguration {

private static final Logger logger = Logger.getLogger(GlobalPluginConfiguration.class.getName());

private boolean enabled = true;

private String server;
Expand Down Expand Up @@ -110,21 +115,29 @@ private void configChange() {
return;
}
if (enabled) {
OpenShiftUtils.initializeOpenShiftClient(server);
this.namespace = getNamespaceOrUseDefault(namespace, getOpenShiftClient());

buildConfigWatcher = new BuildConfigWatcher(namespace);
buildConfigWatcher.start(new Callable<Void>() {
@Override
public Void call() throws Exception {
newBuildWatcher = new NewBuildWatcher(namespace);
newBuildWatcher.start();
cancelledBuildWatcher = new CancelledBuildWatcher(namespace);
cancelledBuildWatcher.start();

return null;
try {
OpenShiftUtils.initializeOpenShiftClient(server);
this.namespace = getNamespaceOrUseDefault(namespace, getOpenShiftClient());

buildConfigWatcher = new BuildConfigWatcher(namespace);
buildConfigWatcher.start(new Callable<Void>() {
@Override
public Void call() throws Exception {
newBuildWatcher = new NewBuildWatcher(namespace);
newBuildWatcher.start();
cancelledBuildWatcher = new CancelledBuildWatcher(namespace);
cancelledBuildWatcher.start();

return null;
}
});
} catch (KubernetesClientException e) {
if (e.getCause() != null) {
logger.log(Level.SEVERE, "Failed to configure OpenShift Jenkins Sync Plugin: " + e.getCause());
} else {
logger.log(Level.SEVERE, "Failed to configure OpenShift Jenkins Sync Plugin: " + e);
}
});
}
}
}

Expand Down