Skip to content

Commit 6ab574a

Browse files
committed
LibraryConfiguration.java: defaultedVersionSCM(): avoid get()ing from empty array [JENKINS-69731]
1 parent 812d12d commit 6ab574a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/org/jenkinsci/plugins/workflow/libs/LibraryConfiguration.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,17 @@ private String defaultedVersionSCM(@NonNull Run<?, ?> run, @NonNull TaskListener
311311
}
312312
try {
313313
WorkflowRun wfRun = (WorkflowRun) run;
314-
scm0 = wfRun.getSCMs().get(0);
314+
Collection<SCM> wfrscms = (Collection<SCM>) wfRun.getSCMs();
315+
if (wfrscms.isEmpty()) {
316+
if (logger != null) {
317+
logger.println("defaultedVersion(): WorkflowRun '" +
318+
wfRun.getClass().getName() +
319+
"' is not associated with any SCMs");
320+
}
321+
} else {
322+
// Somewhat a guess in the dark...
323+
scm0 = wfRun.getSCMs().get(0);
324+
}
315325
} catch (Exception x) {
316326
if (logger != null) {
317327
logger.println("defaultedVersion(): " +

0 commit comments

Comments
 (0)