Skip to content

Commit

Permalink
Support both credential parameter names and values
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Sicker <boards@gmail.com>
  • Loading branch information
jvz committed Jun 21, 2019
1 parent 0b840de commit d8795ce
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,17 @@ public static <C extends IdCredentials> C findCredentialById(@NonNull String id,
String inputUserId = null;
final CredentialsParametersAction action = CredentialsParametersAction.forRun(run);
if (action != null) {
final CredentialsParameterValue parameter = id.startsWith("${") && id.endsWith("}") ?
action.findParameterByName(id.substring(2, id.length() - 1)) :
action.findParameterByName(id); // allow shadowing of credential id by credential parameter name instead
CredentialsParameterValue parameter = null;
if (id.startsWith("${") && id.endsWith("}")) {
// denotes explicitly that this is a parameterized credential
parameter = action.findParameterByName(id.substring(2, id.length() - 1));
} else {
// otherwise, we can check to see if there is a matching credential parameter name or id
parameter = action.findParameterByName(id);
if (parameter == null) {
parameter = action.findParameterByValue(id);
}
}
if (parameter != null) {
isParameter = true;
isDefaultValue = parameter.isDefaultValue();
Expand Down

0 comments on commit d8795ce

Please sign in to comment.