diff options
2 files changed, 17 insertions, 14 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketAdditionalParameterEnvironmentContributor.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketAdditionalParameterEnvironmentContributor.java index a4ff97d..c531ca1 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketAdditionalParameterEnvironmentContributor.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketAdditionalParameterEnvironmentContributor.java @@ -5,7 +5,6 @@ import hudson.Extension; import hudson.model.*; import java.io.IOException; -import java.util.ArrayList; @Extension public class BitbucketAdditionalParameterEnvironmentContributor extends EnvironmentContributor { @@ -18,8 +17,6 @@ public class BitbucketAdditionalParameterEnvironmentContributor extends Environm return; } - run.addAction(getDefaultParameters(run)); - putEnvVar(envVars, "sourceBranch", cause.getSourceBranch()); putEnvVar(envVars, "targetBranch", cause.getTargetBranch()); putEnvVar(envVars, "repositoryOwner", cause.getRepositoryOwner()); @@ -40,14 +37,4 @@ public class BitbucketAdditionalParameterEnvironmentContributor extends Environm return actual == null ? d : actual; } - private ParametersAction getDefaultParameters(Run<?, ?> run) { - ArrayList<ParameterValue> values = new ArrayList<ParameterValue>(); - ParametersDefinitionProperty definitionProperty = run.getParent().getProperty(ParametersDefinitionProperty.class); - if (definitionProperty != null) { - for (ParameterDefinition pd : definitionProperty.getParameterDefinitions()) { - values.add(pd.getDefaultParameterValue()); - } - } - return new ParametersAction(values); - } } diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java index a81e98e..aedfb91 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java @@ -16,6 +16,9 @@ import net.sf.json.JSONObject; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.StaplerRequest; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -160,7 +163,20 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> { } public QueueTaskFuture<?> startJob(BitbucketCause cause) { - return this.job.scheduleBuild2(0, cause, new RevisionParameterAction(cause.getSourceCommitHash())); + Map<String, ParameterValue> values = this.getDefaultParameters(); + return this.job.scheduleBuild2(0, cause, new ParametersAction(new ArrayList(values.values())), new RevisionParameterAction(cause.getSourceCommitHash())); + } + + private Map<String, ParameterValue> getDefaultParameters() { + Map<String, ParameterValue> values = new HashMap<String, ParameterValue>(); + ParametersDefinitionProperty definitionProperty = this.job.getProperty(ParametersDefinitionProperty.class); + + if (definitionProperty != null) { + for (ParameterDefinition definition : definitionProperty.getParameterDefinitions()) { + values.put(definition.getName(), definition.getDefaultParameterValue()); + } + } + return values; } @Override |