Skip to content

Commit 3cb60c0

Browse files
committed
SCMSourceRetrieverTest: drop separate checkDefaultVersion_inline_allowVersionEnvvar_builtIn() [JENKINS-69731]
1 parent 9e20d78 commit 3cb60c0

File tree

1 file changed

+8
-66
lines changed

1 file changed

+8
-66
lines changed

src/test/java/org/jenkinsci/plugins/workflow/libs/SCMSourceRetrieverTest.java

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,82 +1207,24 @@ public class SCMSourceRetrieverTest {
12071207
r.jenkins.reload();
12081208
r.waitUntilNoActivity();
12091209

1210-
WorkflowRun b6 = r.buildAndAssertSuccess(p1);
1211-
r.assertLogContains("Loading library branchylib@stable", b6);
1212-
r.assertLogContains("something reliable", b6);
1213-
r.assertLogContains("Groovy TEST_VAR_NAME missing", b6);
1214-
r.assertLogContains("env.TEST_VAR_NAME='null'", b6);
1215-
1216-
Thread.sleep(160000);
1217-
}
1218-
1219-
@Issue("JENKINS-69731")
1220-
@Test public void checkDefaultVersion_inline_allowVersionEnvvar_builtIn() throws Exception {
1221-
// Test that @Library('branchylib@${env.TEST_VAR_NAME}')
1222-
// is resolved with the TEST_VAR_NAME="feature" in the
1223-
// "built-in" node environment settings.
1224-
1225-
// Do not let caller-provided BRANCH_NAME interfere here
1226-
assumeFalse("An externally provided TEST_VAR_NAME envvar interferes with tested logic",
1227-
System.getenv("TEST_VAR_NAME") != null);
1228-
1229-
// First apply the "built-in node", then touch Jenkins jobs:
1230-
Computer builtInComputer = r.jenkins.toComputer();
1231-
Node builtInNode = builtInComputer.getNode();
1232-
builtInNode.getNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("TEST_VAR_NAME", "stable")));
1233-
r.jenkins.save();
1234-
builtInNode.save();
1235-
1236-
System.out.println("[DEBUG] Restart the 'built-in' Computer connection to clear its cachedEnvironment and recognize added envvar");
1237-
builtInComputer.setTemporarilyOffline(true, new OfflineCause.ByCLI("Restart built-in to reread envvars config"));
1238-
builtInComputer.disconnect(new OfflineCause.ByCLI("Restart built-in to reread envvars config"));
1239-
builtInComputer.waitUntilOffline();
1240-
r.waitUntilNoActivity();
1241-
builtInComputer.getChannel().close();
1242-
Thread.sleep(3000);
1243-
r.jenkins.reload();
1244-
builtInComputer.setTemporarilyOffline(false, null);
1245-
builtInComputer.connect(true);
1246-
builtInComputer.waitUntilOnline();
1247-
r.waitUntilNoActivity();
1248-
12491210
// Feed it to Java reflection, to clear the internal cache...
12501211
Field ccc = Computer.class.getDeclaredField("cachedEnvironment");
12511212
ccc.setAccessible(true);
12521213
ccc.set(builtInComputer, null);
12531214

1254-
System.out.println("[DEBUG] builtIn node env: " + builtInComputer.getEnvironment());
1255-
1256-
sampleRepo.init();
1257-
sampleRepo.write("vars/myecho.groovy", "def call() {echo 'something special'}");
1258-
sampleRepo.git("add", "vars");
1259-
sampleRepo.git("commit", "--message=init");
1260-
sampleRepo.git("checkout", "-b", "feature");
1261-
sampleRepo.write("vars/myecho.groovy", "def call() {echo 'something very special'}");
1262-
sampleRepo.git("add", "vars");
1263-
sampleRepo.git("commit", "--message=init");
1264-
sampleRepo.git("checkout", "-b", "stable");
1265-
sampleRepo.write("vars/myecho.groovy", "def call() {echo 'something reliable'}");
1266-
sampleRepo.git("add", "vars");
1267-
sampleRepo.git("commit", "--message=init");
1268-
SCMSourceRetriever scm = new SCMSourceRetriever(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", true));
1269-
LibraryConfiguration lc = new LibraryConfiguration("branchylib", scm);
1270-
lc.setDefaultVersion("master");
1271-
lc.setIncludeInChangesets(false);
1272-
lc.setAllowVersionOverride(true);
1273-
lc.setAllowVersionEnvvar(true);
1274-
lc.setTraceDefaultedVersion(true);
1275-
GlobalLibraries.get().setLibraries(Collections.singletonList(lc));
1276-
1277-
WorkflowJob p1 = r.jenkins.createProject(WorkflowJob.class, "p1");
1278-
p1.setDefinition(new CpsFlowDefinition("@Library('branchylib@${env.TEST_VAR_NAME}') import myecho; myecho(); try { echo \"Groovy TEST_VAR_NAME='${TEST_VAR_NAME}'\"; } catch (groovy.lang.MissingPropertyException mpe) { echo \"Groovy TEST_VAR_NAME missing: ${mpe.getMessage()}\"; } ; echo \"env.TEST_VAR_NAME='${env.TEST_VAR_NAME}'\"", true));
1279-
1215+
// Still, "built-in" node's envvars are ignored (technically they -
1216+
// now that the cache is cleared - reload global config values for
1217+
// the "MasterComputer" as its own). Checked on standalone instance
1218+
// configured interactively that even a complete Jenkins restart
1219+
// does not let configured "built-in" node envvars become recognized.
1220+
// Loosely related to https://github.com/jenkinsci/jenkins/pull/1728
1221+
// So we keep this test here as a way to notice if core functionality
1222+
// ever changes.
12801223
WorkflowRun b6 = r.buildAndAssertSuccess(p1);
12811224
r.assertLogContains("Loading library branchylib@stable", b6);
12821225
r.assertLogContains("something reliable", b6);
12831226
r.assertLogContains("Groovy TEST_VAR_NAME missing", b6);
12841227
r.assertLogContains("env.TEST_VAR_NAME='null'", b6);
1285-
12861228
}
12871229

12881230
@Issue("JENKINS-43802")

0 commit comments

Comments
 (0)