Skip to content

Commit

Permalink
Add credential input params to build environment
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 13, 2019
1 parent 4e91945 commit 2ac21c3
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.cloudbees.plugins.credentials;

import hudson.EnvVars;
import hudson.model.EnvironmentContributingAction;
import hudson.model.InvisibleAction;
import hudson.model.ParameterValue;
import hudson.model.ParametersAction;
Expand All @@ -13,7 +15,7 @@
import java.util.Iterator;
import java.util.Map;

public class CredentialsParametersAction extends InvisibleAction implements RunAction2, Iterable<CredentialsParameterValue> {
public class CredentialsParametersAction extends InvisibleAction implements RunAction2, EnvironmentContributingAction, Iterable<CredentialsParameterValue> {

private final Map<String, CredentialsParameterValue> values;

Expand Down Expand Up @@ -74,6 +76,13 @@ public void onLoad(Run<?, ?> r) {
// this space intentionally left blank
}

@Override
public void buildEnvironment(@Nonnull Run<?, ?> run, @Nonnull EnvVars env) {
for (Map.Entry<String, CredentialsParameterValue> entry : values.entrySet()) {
env.putIfNotNull(entry.getKey(), entry.getValue().getValue());
}
}

@Override
public @Nonnull Iterator<CredentialsParameterValue> iterator() {
return values.values().iterator();
Expand Down

0 comments on commit 2ac21c3

Please sign in to comment.