Skip to content

Commit

Permalink
[FIXED JENKINS-42027] Actually load GlobalConfig from disk
Browse files Browse the repository at this point in the history
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 5f7ec49
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Expand Up @@ -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);
}
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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() {
Expand Down

0 comments on commit 5f7ec49

Please sign in to comment.