Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-23630] - Honor the sensitive variables engine in Mask Psswords
This change implements API for sensitive variables, which is required to hide passwords in plugins like EnvInject.
  • Loading branch information
oleg-nenashev committed Jul 29, 2015
1 parent 08ca0e0 commit a591ed9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Expand Up @@ -39,13 +39,16 @@
import hudson.model.ParametersAction;
import hudson.tasks.BuildWrapper;
import hudson.tasks.BuildWrapperDescriptor;
import hudson.util.CopyOnWriteMap;
import hudson.util.Secret;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.json.JSONArray;
Expand Down Expand Up @@ -136,6 +139,13 @@ public void makeBuildVariables(AbstractBuild build, Map<String, String> variable
}
}

@Override
public void makeSensitiveBuildVariables(AbstractBuild build, Set<String> sensitiveVariables) {
final Map<String, String> variables = new TreeMap<String, String>();
makeBuildVariables(build, variables);
sensitiveVariables.addAll(variables.keySet());
}

@Override
public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
return new Environment() {
Expand Down
Expand Up @@ -62,6 +62,11 @@ public String resolve(String name) {
};
}

@Override
public final boolean isSensitive() {
return true;
}

public String getValue() {
return value != null ? Secret.toString(value) : null;
}
Expand Down

0 comments on commit a591ed9

Please sign in to comment.