Skip to content
Permalink
Browse files

[FIXED JENKINS-26694] ParameterBuildFilter now works also for Workflo…

…wRun.
  • Loading branch information...
ikedam committed Feb 14, 2015
1 parent abd5a30 commit 53462816b1d9f3455a3422d89bc5d6feaff274f1
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/main/java/hudson/plugins/copyartifact/ParametersBuildFilter.java
@@ -24,8 +24,11 @@
package hudson.plugins.copyartifact;

import hudson.EnvVars;
import hudson.model.ParameterValue;
import hudson.model.TaskListener;
import hudson.model.AbstractBuild;
import hudson.model.Job;
import hudson.model.ParametersAction;
import hudson.model.Run;
import hudson.model.StringParameterValue;
import java.util.ArrayList;
@@ -79,6 +82,22 @@ public boolean isSelectable(Run<?,?> run, EnvVars env) {
} catch (Exception ex) {
return false;
}
if(!(run instanceof AbstractBuild)) {
// Abstract#getEnvironment(TaskListener) put build parameters to
// environments, but Run#getEnvironment(TaskListener) doesn't.
// That means we can't retrieve build parameters from WorkflowRun
// as it is a subclass of Run, not of AbstractBuild.
// We need expand build parameters manually.
// See JENKINS-26694 for details.
for(ParametersAction pa: run.getActions(ParametersAction.class)) {
// We have to extract parameters manally as ParametersAction#buildEnvVars
// (overrides EnvironmentContributingAction#buildEnvVars)
// is applicable only for AbstractBuild.
for(ParameterValue pv: pa.getParameters()) {
pv.buildEnvironment(run, otherEnv);
}
}
}
for (StringParameterValue spv : filters) {
if (!spv.value.equals(otherEnv.get(spv.getName()))) {
return false;

0 comments on commit 5346281

Please sign in to comment.
You can’t perform that action at this time.