Skip to content

Commit f4c53c7

Browse files
committed
SCMSourceRetrieverTest: checkDefaultVersion_inline_allowVersionEnvvar(): WorkflowRun only accepts injected envvars if global config does not override them [JENKINS-69731]
1 parent 06a3e09 commit f4c53c7

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,28 @@ public class SCMSourceRetrieverTest {
11031103
System.out.println("[DEBUG:EXT] wfRun env: " + b2.getEnvironment());
11041104
System.out.println("[DEBUG:EXT] wfRun envContribActions: " + b2.getActions(EnvironmentContributingAction.class));
11051105

1106-
r.assertLogContains("Loading library branchylib@feature", b2);
1107-
r.assertLogContains("something very special", b2);
1106+
// Our first try is expected to fail currently, since
1107+
// WorkflowRun::buildEnvironmentFor() takes "env" from
1108+
// super-class, and overlays with envvars from global
1109+
// configuration. However, if in the future behavior
1110+
// of workflow changes, it is not consequential - just
1111+
// something to adjust "correct" expectations for.
1112+
r.assertLogContains("Loading library branchylib@stable", b2);
1113+
r.assertLogContains("something reliable", b2);
1114+
1115+
// For the next try, however, we remove global config
1116+
// part and expect the injected envvar to take hold:
1117+
envVars.remove("TEST_VAR_NAME");
1118+
r.jenkins.save();
1119+
1120+
WorkflowRun b3 = r.buildAndAssertSuccess(p1);
1121+
1122+
System.out.println("[DEBUG:EXT] wfJob env: " + p1.getEnvironment(null, null));
1123+
System.out.println("[DEBUG:EXT] wfRun env: " + b3.getEnvironment());
1124+
System.out.println("[DEBUG:EXT] wfRun envContribActions: " + b3.getActions(EnvironmentContributingAction.class));
1125+
1126+
r.assertLogContains("Loading library branchylib@feature", b3);
1127+
r.assertLogContains("something very special", b3);
11081128
}
11091129
}
11101130

0 commit comments

Comments
 (0)