Skip to content

Commit 462a65c

Browse files
committed
[FIXED JENKINS-8342] Pulled from hajoeichler and added testcase to verify the issue
1 parent ae3f386 commit 462a65c

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

src/test/java/hudson/plugins/git/GitSCMTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import hudson.plugins.git.opt.PreBuildMergeOptions;
1616
import hudson.plugins.git.util.DefaultBuildChooser;
1717
import hudson.util.StreamTaskListener;
18+
19+
import org.jvnet.hudson.test.Bug;
1820
import org.jvnet.hudson.test.CaptureEnvironmentBuilder;
1921
import org.jvnet.hudson.test.HudsonTestCase;
2022

@@ -88,6 +90,33 @@ public void testBasicExcludedRegion() throws Exception {
8890
assertFalse("scm polling should not detect any more changes after build", project.pollSCMChanges(listener));
8991
}
9092

93+
@Bug(value = 8342)
94+
public void testExcludedRegionMultiCommit() throws Exception {
95+
// Got 2 projects, each one should only build if changes in its own file
96+
FreeStyleProject clientProject = setupProject("master", false, null, ".*serverFile", null);
97+
FreeStyleProject serverProject = setupProject("master", false, null, ".*clientFile", null);
98+
String initialCommitFile = "initialFile";
99+
commit(initialCommitFile, johnDoe, "initial commit");
100+
build(clientProject, Result.SUCCESS, initialCommitFile);
101+
build(serverProject, Result.SUCCESS, initialCommitFile);
102+
103+
assertFalse("scm polling should not detect any more changes after initial build", clientProject.poll(listener).hasChanges());
104+
assertFalse("scm polling should not detect any more changes after initial build", serverProject.poll(listener).hasChanges());
105+
106+
// Got commits on serverFile, so only server project should build.
107+
commit("myserverFile", johnDoe, "commit first server file");
108+
109+
assertFalse("scm polling should not detect any changes in client project", clientProject.poll(listener).hasChanges());
110+
assertTrue("scm polling did not detect changes in server project", serverProject.poll(listener).hasChanges());
111+
112+
// Got commits on both client and serverFile, so both projects should build.
113+
commit("myNewserverFile", johnDoe, "commit new server file");
114+
commit("myclientFile", johnDoe, "commit first clientfile");
115+
116+
assertTrue("scm polling did not detect changes in client project", clientProject.poll(listener).hasChanges());
117+
assertTrue("scm polling did not detect changes in server project", serverProject.poll(listener).hasChanges());
118+
}
119+
91120
public void testBasicExcludedUser() throws Exception {
92121
FreeStyleProject project = setupProject("master", false, null, null, "Jane Doe");
93122

0 commit comments

Comments
 (0)