Skip to content

Commit

Permalink
Merge pull request #6 from oleg-nenashev/JENKINS-29867-hide-envvars
Browse files Browse the repository at this point in the history
[JENKINS-29867] - Expose owner runs in the action
  • Loading branch information
oleg-nenashev committed Aug 10, 2015
2 parents caf1a25 + fa6e1a0 commit 9ffb287
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java
Expand Up @@ -4,6 +4,7 @@
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Run;
import org.apache.commons.collections.map.UnmodifiableMap;
import org.jenkinsci.lib.envinject.service.EnvInjectSavable;
import org.kohsuke.stapler.StaplerProxy;
Expand All @@ -14,7 +15,9 @@
import java.util.Map;
import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

//TODO: Convert to RunAction2
/**
* @author Gregory Boissinot
*/
Expand All @@ -23,8 +26,8 @@ public class EnvInjectAction implements Action, StaplerProxy {
public static final String URL_NAME = "injectedEnvVars";

protected transient @CheckForNull Map<String, String> envMap;

private AbstractBuild build;
private @Nonnull AbstractBuild build;

/**
* Backward compatibility
Expand All @@ -33,7 +36,7 @@ public class EnvInjectAction implements Action, StaplerProxy {
private transient File rootDir;
private transient @CheckForNull Set<String> sensibleVariables;

public EnvInjectAction(AbstractBuild build,
public EnvInjectAction(@Nonnull AbstractBuild build,
@CheckForNull Map<String, String> envMap) {
this.build = build;
this.envMap = envMap;
Expand Down Expand Up @@ -111,7 +114,7 @@ public String transformEntry(String key, String value) {
}


private Map<String, String> getEnvironment(AbstractBuild build) throws EnvInjectException {
private Map<String, String> getEnvironment(@CheckForNull AbstractBuild build) throws EnvInjectException {

if (build == null) {
return null;
Expand All @@ -126,7 +129,15 @@ private Map<String, String> getEnvironment(AbstractBuild build) throws EnvInject
return dao.getEnvironment(build.getRootDir());
}


/**
* Retrieves an owner {@link Run} of this action.
* @return {@link Run}, which contains the action
* @since TODO
*/
public Run<?,?> getOwner() {
return build;
}

@SuppressWarnings("unused")
private Object readResolve() throws ObjectStreamException {

Expand Down

0 comments on commit 9ffb287

Please sign in to comment.