Skip to content

Commit 148f87d

Browse files
authored
Revert "Allowing empty valued global variables in config file (#2657)" (#2663)
This reverts commit 506f96a.
1 parent 6fadd55 commit 148f87d

File tree

4 files changed

+3
-114
lines changed

4 files changed

+3
-114
lines changed

integrations/src/test/java/io/jenkins/plugins/casc/GlobalNodePropertiesTest.java

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@
77
import static org.hamcrest.core.Is.is;
88
import static org.junit.jupiter.api.Assertions.assertEquals;
99

10-
import hudson.node_monitors.DiskSpaceMonitorNodeProperty;
1110
import hudson.slaves.EnvironmentVariablesNodeProperty;
1211
import hudson.slaves.NodeProperty;
1312
import hudson.slaves.NodePropertyDescriptor;
14-
import hudson.tools.ToolLocationNodeProperty;
1513
import hudson.util.DescribableList;
1614
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
1715
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
1816
import io.jenkins.plugins.casc.misc.junit.jupiter.WithJenkinsConfiguredWithCode;
1917
import io.jenkins.plugins.casc.model.CNode;
20-
import java.util.Iterator;
2118
import java.util.Map;
22-
import java.util.Map.Entry;
2319
import java.util.Set;
2420
import jenkins.model.Jenkins;
2521
import org.junit.jupiter.api.Test;
@@ -34,37 +30,14 @@ void configure(JenkinsConfiguredWithCodeRule j) {
3430

3531
DescribableList<NodeProperty<?>, NodePropertyDescriptor> nodeProperties = jenkins.getGlobalNodeProperties();
3632

37-
assertEquals(3, nodeProperties.size());
38-
39-
Set<Map.Entry<String, String>> envVars = ((EnvironmentVariablesNodeProperty)
40-
nodeProperties.get(EnvironmentVariablesNodeProperty.class))
33+
Set<Map.Entry<String, String>> entries = ((EnvironmentVariablesNodeProperty) nodeProperties.get(0))
4134
.getEnvVars()
4235
.entrySet();
43-
assertEquals(3, envVars.size());
36+
assertEquals(1, entries.size());
4437

45-
Iterator<Entry<String, String>> iterator = envVars.iterator();
46-
Map.Entry<String, String> envVar = iterator.next();
38+
Map.Entry<String, String> envVar = entries.iterator().next();
4739
assertEquals("FOO", envVar.getKey());
4840
assertEquals("BAR", envVar.getValue());
49-
50-
envVar = iterator.next();
51-
assertEquals("FOO2", envVar.getKey());
52-
assertEquals("", envVar.getValue());
53-
54-
envVar = iterator.next();
55-
assertEquals("FOO3", envVar.getKey());
56-
assertEquals("", envVar.getValue());
57-
58-
DiskSpaceMonitorNodeProperty diskSpace = nodeProperties.get(DiskSpaceMonitorNodeProperty.class);
59-
assertEquals("1GiB", diskSpace.getFreeDiskSpaceThreshold());
60-
assertEquals("2GiB", diskSpace.getFreeDiskSpaceWarningThreshold());
61-
assertEquals("1GiB", diskSpace.getFreeTempSpaceThreshold());
62-
assertEquals("2GiB", diskSpace.getFreeTempSpaceWarningThreshold());
63-
64-
ToolLocationNodeProperty toolLocations = nodeProperties.get(ToolLocationNodeProperty.class);
65-
assertEquals(1, toolLocations.getLocations().size());
66-
assertEquals("Default", toolLocations.getLocations().get(0).getName());
67-
assertEquals("/home/user/bin/git", toolLocations.getLocations().get(0).getHome());
6841
}
6942

7043
@Test
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
jenkins:
22
globalNodeProperties:
3-
- diskSpaceMonitor:
4-
freeDiskSpaceThreshold: "1GiB"
5-
freeDiskSpaceWarningThreshold: "2GiB"
6-
freeTempSpaceThreshold: "1GiB"
7-
freeTempSpaceWarningThreshold: "2GiB"
83
- envVars:
94
env:
105
- key: FOO
116
value: BAR
12-
- key: FOO2
13-
value: ""
14-
- key: FOO3
15-
- toolLocation:
16-
locations:
17-
- home: "/home/user/bin/git"
18-
key: "hudson.plugins.git.GitTool$DescriptorImpl@Default"
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
- diskSpaceMonitor:
2-
freeDiskSpaceThreshold: "1GiB"
3-
freeDiskSpaceWarningThreshold: "2GiB"
4-
freeTempSpaceThreshold: "1GiB"
5-
freeTempSpaceWarningThreshold: "2GiB"
61
- envVars:
72
env:
83
- key: "FOO"
94
value: "BAR"
10-
- key: "FOO2"
11-
- key: "FOO3"
12-
- toolLocation:
13-
locations:
14-
- home: "/home/user/bin/git"
15-
key: "hudson.plugins.git.GitTool$DescriptorImpl@Default"

plugin/src/main/java/io/jenkins/plugins/casc/core/GlobalNodePropertiesConfigurator.java

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)