@@ -1207,82 +1207,24 @@ public class SCMSourceRetrieverTest {
1207
1207
r .jenkins .reload ();
1208
1208
r .waitUntilNoActivity ();
1209
1209
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
-
1249
1210
// Feed it to Java reflection, to clear the internal cache...
1250
1211
Field ccc = Computer .class .getDeclaredField ("cachedEnvironment" );
1251
1212
ccc .setAccessible (true );
1252
1213
ccc .set (builtInComputer , null );
1253
1214
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.
1280
1223
WorkflowRun b6 = r .buildAndAssertSuccess (p1 );
1281
1224
r .assertLogContains ("Loading library branchylib@stable" , b6 );
1282
1225
r .assertLogContains ("something reliable" , b6 );
1283
1226
r .assertLogContains ("Groovy TEST_VAR_NAME missing" , b6 );
1284
1227
r .assertLogContains ("env.TEST_VAR_NAME='null'" , b6 );
1285
-
1286
1228
}
1287
1229
1288
1230
@ Issue ("JENKINS-43802" )
0 commit comments