diff --git a/src/main/java/org/jenkinsci/plugins/azurekeyvaultplugin/AzureCredentialsProvider.java b/src/main/java/org/jenkinsci/plugins/azurekeyvaultplugin/AzureCredentialsProvider.java index 5cba031..8bfa0f3 100644 --- a/src/main/java/org/jenkinsci/plugins/azurekeyvaultplugin/AzureCredentialsProvider.java +++ b/src/main/java/org/jenkinsci/plugins/azurekeyvaultplugin/AzureCredentialsProvider.java @@ -21,6 +21,7 @@ import java.net.URL; import java.time.Duration; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -124,9 +125,12 @@ private static Collection fetchCredentials() { tags = new HashMap<>(); } - if (StringUtils.isNotBlank(labelSelector) && !labelSelector.equals(tags.get("jenkins-label"))) { - // User specified a label selector in config, but current credential does not contain a matching tag, skip iteration - continue; + if (StringUtils.isNotBlank(labelSelector)) { + String jenkinsLabels = tags.getOrDefault("jenkins-label", ""); + List labelSelectors = Arrays.asList(jenkinsLabels.split(",")); + if (!labelSelectors.contains(labelSelector)) { + continue; + } } String type = tags.getOrDefault("type", DEFAULT_TYPE);