@@ -219,7 +219,7 @@ public class SCMSourceRetrieverTest {
219219 }
220220
221221 @ Issue ("JENKINS-69731" )
222- @ Test public void checkDefaultVersion () throws Exception {
222+ @ Test public void checkDefaultVersionStaticStrings () throws Exception {
223223 sampleRepo .init ();
224224 sampleRepo .write ("vars/myecho.groovy" , "def call() {echo 'something special'}" );
225225 sampleRepo .git ("add" , "vars" );
@@ -239,25 +239,32 @@ public class SCMSourceRetrieverTest {
239239 WorkflowJob p0 = r .jenkins .createProject (WorkflowJob .class , "p0" );
240240 p0 .setDefinition (new CpsFlowDefinition ("@Library('branchylib') import myecho; myecho()" , true ));
241241 WorkflowRun b0 = r .buildAndAssertSuccess (p0 );
242+ r .assertLogContains ("Loading library branchylib@master" , b0 );
242243 r .assertLogContains ("something special" , b0 );
243244
244245 // Use specified branch
245246 WorkflowJob p1 = r .jenkins .createProject (WorkflowJob .class , "p1" );
246247 p1 .setDefinition (new CpsFlowDefinition ("@Library('branchylib@master') import myecho; myecho()" , true ));
247248 WorkflowRun b1 = r .buildAndAssertSuccess (p1 );
249+ r .assertLogContains ("Loading library branchylib@master" , b1 );
248250 r .assertLogContains ("something special" , b1 );
249251
250252 // Use another specified branch
251253 WorkflowJob p2 = r .jenkins .createProject (WorkflowJob .class , "p2" );
252254 p2 .setDefinition (new CpsFlowDefinition ("@Library('branchylib@feature') import myecho; myecho()" , true ));
253255 WorkflowRun b2 = r .buildAndAssertSuccess (p2 );
256+ r .assertLogContains ("Loading library branchylib@feature" , b2 );
254257 r .assertLogContains ("something very special" , b2 );
255258
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+ }
261268
262269 // Use a specified but missing branch
263270 WorkflowJob p4 = r .jenkins .createProject (WorkflowJob .class , "p4" );
0 commit comments