diff --git a/pullrequests/src/main/java/com/arcbees/pullrequest/PullRequestsTrigger.java b/pullrequests/src/main/java/com/arcbees/pullrequest/PullRequestsTrigger.java index cecb260..06709ad 100644 --- a/pullrequests/src/main/java/com/arcbees/pullrequest/PullRequestsTrigger.java +++ b/pullrequests/src/main/java/com/arcbees/pullrequest/PullRequestsTrigger.java @@ -16,6 +16,7 @@ package com.arcbees.pullrequest; +import com.google.common.collect.Maps; import java.io.IOException; import java.util.List; import java.util.Map; @@ -73,7 +74,6 @@ public PullRequestsTrigger( public void triggerBuild(@NotNull PolledTriggerContext context) throws BuildTriggerException { BuildTriggerDescriptor triggerDescriptor = context.getTriggerDescriptor(); Map properties = triggerDescriptor.getProperties(); - VcsPropertiesHelper vcsPropertiesHelper = new VcsPropertiesHelper(properties, vcsConstants); String repositoryOwner = vcsPropertiesHelper.getRepositoryOwner(); String repositoryName = vcsPropertiesHelper.getRepositoryName(); @@ -129,18 +129,24 @@ private boolean addBuildTask(PolledTriggerContext context, List tri boolean added = false; if (!lastCommit.getHash().equals(lastTriggeredCommitHash)) { - addBuildTask(context, triggerTasks, source); + addBuildTask(context, triggerTasks, pullRequest); added = true; } return added; } - private void addBuildTask(PolledTriggerContext context, List triggerTasks, PullRequestTarget source) { + private void addBuildTask(PolledTriggerContext context, List triggerTasks, PullRequest pullRequest) { + PullRequestTarget source = pullRequest.getSource(); BuildTypeEx buildType = (BuildTypeEx) context.getBuildType(); + BuildCustomizer buildCustomizer = buildCustomizerFactory.createBuildCustomizer(buildType, null); buildCustomizer.setCleanSources(true); + Map parameters = Maps.newHashMap(); + parameters.put("trigger.pullRequestId", String.valueOf(pullRequest.getId())); + buildCustomizer.setParameters(parameters); + BranchEx branch = buildType.getBranchByDisplayName(source.getBranch().getName()); SVcsModification lastModification = checkChanges(source.getCommit().getHash(), branch.getDummyBuild().getChanges(SelectPrevBuildPolicy.SINCE_NULL_BUILD, true));