Skip to content
Permalink
Browse files

JENKINS-28709 Join Plugin ignores dependencies wrapped with flexible-…

…publish

(https://issues.jenkins-ci.org/browse/JENKINS-28709)

Now it can handle "hudson.plugins.parameterizedtrigger.BuildTrigger"  in Flexible publisher!
  • Loading branch information...
俞韋廷
俞韋廷 committed May 23, 2016
1 parent d8c5851 commit 246a1fb66f5c39b5f36489014269937668d58412
Showing with 50 additions and 0 deletions.
  1. +5 −0 pom.xml
  2. +45 −0 src/main/java/join/JoinTrigger.java
@@ -56,6 +56,11 @@
<version>2.12</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>flexible-publish</artifactId>
<version>0.15.2</version>
</dependency>
</dependencies>

<properties>
@@ -64,12 +64,15 @@
import join.JoinAction.JoinCause;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.jenkins_ci.plugins.flexible_publish.ConditionalPublisher;
import org.jenkins_ci.plugins.flexible_publish.FlexiblePublisher;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.StringTokenizer;
import java.util.logging.Level;
@@ -210,6 +213,46 @@ public void buildDependencyGraph(AbstractProject owner, DependencyGraph graph) {
return ret;
}

private Collection<? extends AbstractProject<?, ?>> getParameterizedDownstreamInFlexiblePublisher(
AbstractProject<?, ?> project) {

DescribableList<Publisher, Descriptor<Publisher>> publishers = project.getPublishersList();
List<AbstractProject<?, ?>> ret = new ArrayList<AbstractProject<?, ?>>();

FlexiblePublisher flexiblePublisher = publishers.get(FlexiblePublisher.class);

if (flexiblePublisher != null ) {

for (ConditionalPublisher conditionalPublisher : flexiblePublisher.getPublishers()) {
for (BuildStep buildStep : conditionalPublisher.getPublisherList()) {
if (buildStep instanceof hudson.plugins.parameterizedtrigger.BuildTrigger) {

ret.addAll(GetProjectFromBuildTriggerConfigs((hudson.plugins.parameterizedtrigger.BuildTrigger)buildStep));
}
}
}
}

return ret;
}

private Collection<? extends AbstractProject<?, ?>> GetProjectFromBuildTriggerConfigs(
hudson.plugins.parameterizedtrigger.BuildTrigger buildTrigger) {

List<AbstractProject<?, ?>> ret = new ArrayList<AbstractProject<?, ?>>();

for (hudson.model.Project p : Hudson.getInstance().getProjects()) {

for (BuildTriggerConfig config : buildTrigger.getConfigs()) {
if (p.getName().equals(config.getProjects())) {
ret.add(p);
}
}
}

return ret;
}

static boolean canDeclare(AbstractProject<?,?> owner) {
// Inner class added in Hudson 1.341
return true;
@@ -218,10 +261,12 @@ static boolean canDeclare(AbstractProject<?,?> owner) {

public List<AbstractProject<?,?>> getAllDownstream(AbstractProject<?,?> project, EnvVars env) {
List<AbstractProject<?,?>> downstream = getBuildTriggerDownstream(project);
downstream.addAll(getParameterizedDownstreamInFlexiblePublisher(project));
downstream.addAll(getParameterizedDownstreamProjects(project.getParent(), project.getPublishersList(), env));
downstream.addAll(getDownstreamExtDownstream(project.getParent(), project.getPublishersList()));
return downstream;
}


public List<AbstractProject<?,?>> getBuildTriggerDownstream(AbstractProject<?,?> project) {
ArrayList<AbstractProject<?,?>> ret = new ArrayList<AbstractProject<?,?>>();

0 comments on commit 246a1fb

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