Skip to content

Commit

Permalink
Merge pull request #4 from milowg/feature/MentionedInCommitOrUpstream…
Browse files Browse the repository at this point in the history
…CommitsStrategy

Fixed to support multiple upstreams
  • Loading branch information
milowg authored Aug 28, 2018
2 parents a799d8c + eea73d8 commit 817b91f
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -48,10 +53,11 @@ public List<JiraCommit> getJiraCommits(AbstractBuild build,
try
{
_logger.log(Level.FINE, "iterateTicketsAndApply");
ChangeLogSet changeSets = build.getChangeSet();
listener.getLogger().println("ChangeLogSet class: " + changeSets.getClass());
List<Object> changeSetEntries = new LinkedList<>();

for (Object entry : changeSets)
getBuildChangeSetEntries(listener, build, changeSetEntries);

for (Object entry : changeSetEntries)
{
try
{
Expand Down Expand Up @@ -81,6 +87,14 @@ public List<JiraCommit> getJiraCommits(AbstractBuild build,
return result;
}

private void getBuildChangeSetEntries(BuildListener listener, AbstractBuild build, List<Object> 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.
*
Expand Down

0 comments on commit 817b91f

Please sign in to comment.