Skip to content
Permalink
Browse files
[FIXED JENKINS-42027] Actually load GlobalConfig from disk
We weren't doing this before, and so the settings in GlobalConfig
weren't being persisted. That was an oopsie, but this is an easy fix.
  • Loading branch information
abayer committed Feb 14, 2017
1 parent aaa0593 commit 5f7ec49127f9f68d5299b7dc70fab0f59a336dcd
@@ -50,6 +50,10 @@ public class GlobalConfig extends GlobalConfiguration {
private String dockerLabel;
private DockerRegistryEndpoint registry;

public GlobalConfig() {
load();
}

public String getDockerLabel() {
return Util.fixEmpty(dockerLabel);
}
@@ -27,6 +27,7 @@
import hudson.model.labels.LabelAtom;
import hudson.slaves.DumbSlave;
import hudson.slaves.EnvironmentVariablesNodeProperty;
import org.jenkinsci.plugins.pipeline.modeldefinition.config.GlobalConfig;
import org.jenkinsci.plugins.workflow.actions.WorkspaceAction;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker;
@@ -39,6 +40,7 @@
import org.junit.Test;
import org.junit.runners.model.Statement;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.RestartableJenkinsRule;

import java.util.ArrayList;
@@ -55,6 +57,25 @@ public class DurabilityTest {
@Rule
public RestartableJenkinsRule story = new RestartableJenkinsRule();

@Issue("JENKINS-42027")
@Test
public void globalConfigPersists() throws Exception {
story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
GlobalConfig.get().setDockerLabel("config_docker");
GlobalConfig.get().save();
}
});

story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
assertEquals("config_docker", GlobalConfig.get().getDockerLabel());
}
});
}

@Test
public void survivesRestart() throws Exception {
story.addStep(new Statement() {

0 comments on commit 5f7ec49

Please sign in to comment.