提交 ba67cdd1 编写于 作者: K kohsuke

Generalized ParametersAction so that this benefits other plugins, too.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@20201 71c3de6d-444a-0410-be80-ed276b4c234a
上级 d61538c8
......@@ -465,10 +465,9 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
for (Environment e : buildEnvironments)
e.buildEnvVars(env);
ParametersAction parameters = getAction(ParametersAction.class);
if (parameters != null)
parameters.buildEnvVars(this,env);
for (EnvironmentContributingAction a : Util.filter(getActions(),EnvironmentContributingAction.class))
a.buildEnvVars(this,env);
EnvVars.resolve(env);
return env;
......
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model;
import hudson.EnvVars;
import hudson.tasks.Builder;
import hudson.tasks.BuildWrapper;
/**
* {@link Action} that contributes environment variables during a build.
*
* @author Kohsuke Kawaguchi
* @since 1.318
* @see AbstractBuild#getEnvironment(TaskListener)
* @see BuildWrapper
*/
public interface EnvironmentContributingAction extends Action {
/**
* Called by {@link AbstractBuild} to allow plugins to contribute environment variables.
*
* <p>
* For example, your {@link Builder} can add an {@link EnvironmentContributingAction} so that
* the rest of the builders or publishers see some behavior changes.
*
* @param build
* The calling build. Never null.
* @param env
* Evironment variables should be added to this map.
*/
public void buildEnvVars(AbstractBuild<?,?> build, EnvVars env);
}
......@@ -24,6 +24,7 @@
package hudson.model;
import hudson.Util;
import hudson.EnvVars;
import hudson.model.Queue.QueueAction;
import hudson.tasks.BuildStep;
import hudson.tasks.BuildWrapper;
......@@ -49,7 +50,7 @@ import java.util.Set;
* that were specified when scheduling.
*/
@ExportedBean
public class ParametersAction implements Action, Iterable<ParameterValue>, QueueAction {
public class ParametersAction implements Action, Iterable<ParameterValue>, QueueAction, EnvironmentContributingAction {
private final List<ParameterValue> parameters;
......@@ -73,7 +74,7 @@ public class ParametersAction implements Action, Iterable<ParameterValue>, Queue
}
}
public void buildEnvVars(AbstractBuild<?,?> build, Map<String,String> env) {
public void buildEnvVars(AbstractBuild<?,?> build, EnvVars env) {
for (ParameterValue p : parameters)
p.buildEnvVars(build,env);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册