@@ -219,7 +219,7 @@ public class SCMSourceRetrieverTest {
219
219
}
220
220
221
221
@ Issue ("JENKINS-69731" )
222
- @ Test public void checkDefaultVersion () throws Exception {
222
+ @ Test public void checkDefaultVersionStaticStrings () throws Exception {
223
223
sampleRepo .init ();
224
224
sampleRepo .write ("vars/myecho.groovy" , "def call() {echo 'something special'}" );
225
225
sampleRepo .git ("add" , "vars" );
@@ -239,25 +239,32 @@ public class SCMSourceRetrieverTest {
239
239
WorkflowJob p0 = r .jenkins .createProject (WorkflowJob .class , "p0" );
240
240
p0 .setDefinition (new CpsFlowDefinition ("@Library('branchylib') import myecho; myecho()" , true ));
241
241
WorkflowRun b0 = r .buildAndAssertSuccess (p0 );
242
+ r .assertLogContains ("Loading library branchylib@master" , b0 );
242
243
r .assertLogContains ("something special" , b0 );
243
244
244
245
// Use specified branch
245
246
WorkflowJob p1 = r .jenkins .createProject (WorkflowJob .class , "p1" );
246
247
p1 .setDefinition (new CpsFlowDefinition ("@Library('branchylib@master') import myecho; myecho()" , true ));
247
248
WorkflowRun b1 = r .buildAndAssertSuccess (p1 );
249
+ r .assertLogContains ("Loading library branchylib@master" , b1 );
248
250
r .assertLogContains ("something special" , b1 );
249
251
250
252
// Use another specified branch
251
253
WorkflowJob p2 = r .jenkins .createProject (WorkflowJob .class , "p2" );
252
254
p2 .setDefinition (new CpsFlowDefinition ("@Library('branchylib@feature') import myecho; myecho()" , true ));
253
255
WorkflowRun b2 = r .buildAndAssertSuccess (p2 );
256
+ r .assertLogContains ("Loading library branchylib@feature" , b2 );
254
257
r .assertLogContains ("something very special" , b2 );
255
258
256
- // Branch context for job not set - fall back to default
257
- WorkflowJob p3 = r .jenkins .createProject (WorkflowJob .class , "p3" );
258
- p3 .setDefinition (new CpsFlowDefinition ("@Library('branchylib@${BRANCH_NAME}') import myecho; myecho()" , true ));
259
- WorkflowRun b3 = r .buildAndAssertSuccess (p3 );
260
- r .assertLogContains ("something special" , b3 );
259
+ // Do not let caller-provided BRANCH_NAME interfere here
260
+ if (System .getenv ("BRANCH_NAME" ) == null ) {
261
+ // Branch context for job not set - fall back to default
262
+ WorkflowJob p3 = r .jenkins .createProject (WorkflowJob .class , "p3" );
263
+ p3 .setDefinition (new CpsFlowDefinition ("@Library('branchylib@${BRANCH_NAME}') import myecho; myecho()" , true ));
264
+ WorkflowRun b3 = r .buildAndAssertSuccess (p3 );
265
+ r .assertLogContains ("Loading library branchylib@master" , b3 );
266
+ r .assertLogContains ("something special" , b3 );
267
+ }
261
268
262
269
// Use a specified but missing branch
263
270
WorkflowJob p4 = r .jenkins .createProject (WorkflowJob .class , "p4" );
0 commit comments