From eea73d885f8f8f850ad54b5333707c7ec8f7afa0 Mon Sep 17 00:00:00 2001 From: Gil Milow Date: Mon, 27 Aug 2018 21:19:57 -0400 Subject: [PATCH] Fixed to support multiple upstreams --- .../view/AbstractParsingIssueStrategy.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/jiraext/view/AbstractParsingIssueStrategy.java b/src/main/java/org/jenkinsci/plugins/jiraext/view/AbstractParsingIssueStrategy.java index 7ab914d..7b5df86 100644 --- a/src/main/java/org/jenkinsci/plugins/jiraext/view/AbstractParsingIssueStrategy.java +++ b/src/main/java/org/jenkinsci/plugins/jiraext/view/AbstractParsingIssueStrategy.java @@ -18,19 +18,24 @@ **************************************************************************/ package org.jenkinsci.plugins.jiraext.view; +import com.google.common.collect.Iterators; +import com.google.common.collect.Lists; import hudson.model.AbstractBuild; +import hudson.model.AbstractProject; import hudson.model.BuildListener; import hudson.scm.ChangeLogSet; import org.jenkinsci.plugins.jiraext.domain.JiraCommit; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; /** * An IssueStrategyExtension which assumes you want to return a list of jira commits by - * deriving them from the provided build's {@link ChangeLogSet} + * deriving them from the provided build's {@link ChangeLogSet}. Also includes upstream build ChangeLogSets * * @author dalvizu */ @@ -48,10 +53,11 @@ public List getJiraCommits(AbstractBuild build, try { _logger.log(Level.FINE, "iterateTicketsAndApply"); - ChangeLogSet changeSets = build.getChangeSet(); - listener.getLogger().println("ChangeLogSet class: " + changeSets.getClass()); + List changeSetEntries = new LinkedList<>(); - for (Object entry : changeSets) + getBuildChangeSetEntries(listener, build, changeSetEntries); + + for (Object entry : changeSetEntries) { try { @@ -81,6 +87,14 @@ public List getJiraCommits(AbstractBuild build, return result; } + private void getBuildChangeSetEntries(BuildListener listener, AbstractBuild build, List changeSetEntries) { + ChangeLogSet changeSets = build.getChangeSet(); + String projectName = build.getProject() == null ? "" : build.getProject().getName(); + Integer buildNumber = build.getNumber(); + listener.getLogger().println(String.format("ChangeLogSet from %s build %d, class: %s", projectName, buildNumber, changeSets.getClass())); + changeSetEntries.addAll(Lists.newArrayList(changeSets.iterator())); + } + /** * Parse a JIRA issue key, ie SSD-101, out of the given ChangeLogSet.Entry. *