提交 6508275d 编写于 作者: K kohsuke

[FIXED HUDSON-2778] Fixed and added a test case.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@14073 71c3de6d-444a-0410-be80-ed276b4c234a
上级 4bf68f1a
......@@ -829,15 +829,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
public final List<AbstractProject> getBuildTriggerUpstreamProjects() {
ArrayList<AbstractProject> result = new ArrayList<AbstractProject>();
for (AbstractProject ap : getUpstreamProjects()) {
if (ap instanceof Project) {
Project p = (Project) ap;
BuildTrigger buildTrigger = (BuildTrigger)p.getPublisher(BuildTrigger.DESCRIPTOR);
if (buildTrigger != null) {
if (buildTrigger.getChildProjects().contains(this)) {
result.add(p);
}
}
}
BuildTrigger buildTrigger = (BuildTrigger)ap.getPublishersList().get(BuildTrigger.DESCRIPTOR);
if (buildTrigger != null)
if (buildTrigger.getChildProjects().contains(this))
result.add(ap);
}
return result;
}
......
......@@ -8,7 +8,7 @@
<j:set var="up" value="${it.buildTriggerUpstreamProjects}" />
<f:optionalBlock name="pseudoUpstreamTrigger"
help="/help/project-config/upstream.html"
title="${%Build after other projects are built}"
title="${%Build after other projects are built} ${it.buildTriggerUpstreamProjects}"
checked="${!empty(up)}">
<f:entry title="${%Projects names}"
description="${%Multiple projects can be specified like 'abc, def'}">
......
......@@ -4,6 +4,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.tasks.Builder;
import hudson.tasks.Shell;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.HudsonTestCase;
import java.util.List;
......@@ -35,4 +36,38 @@ public class FreeStyleProjectTest extends HudsonTestCase {
assertEquals("echo hello",((Shell)builders.get(0)).getCommand());
assertTrue(builders.get(0)!=shell);
}
/**
* Make sure that the pseudo trigger configuration works.
*/
@Bug(2778)
public void testUpstreamPseudoTrigger() throws Exception {
pseudoTriggerTest(createMavenProject(), createFreeStyleProject());
}
@Bug(2778)
public void testUpstreamPseudoTrigger2() throws Exception {
pseudoTriggerTest(createFreeStyleProject(), createFreeStyleProject());
}
@Bug(2778)
public void testUpstreamPseudoTrigger3() throws Exception {
pseudoTriggerTest(createMatrixProject(), createFreeStyleProject());
}
private void pseudoTriggerTest(AbstractProject up, AbstractProject down) throws Exception {
HtmlForm form = new WebClient().getPage(down, "configure").getFormByName("config");
form.getInputByName("pseudoUpstreamTrigger").setChecked(true);
form.getInputByName("upstreamProjects").setValueAttribute(up.getName());
submit(form);
// make sure this took effect
assertTrue(up.getDownstreamProjects().contains(down));
assertTrue(down.getUpstreamProjects().contains(up));
// round trip again and verify that the configuration is still intact.
submit(new WebClient().getPage(down, "configure").getFormByName("config"));
assertTrue(up.getDownstreamProjects().contains(down));
assertTrue(down.getUpstreamProjects().contains(up));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册