File otherRepo = tmp.newFolder();
hg(otherRepo, "init");
FileUtils.touch(new File(otherRepo, "otherfile"));
hg(otherRepo, "add", "otherfile");
hg(otherRepo, "commit", "--message=init");
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "demo");
p.addTrigger(new SCMTrigger(""));
p.setQuietPeriod(3); // so it only does one build
p.setDefinition(new CpsFlowDefinition(
"node {\n" +
" ws {\n" +
" dir('main') {\n" +
" checkout([$class: 'MercurialSCM', source: '" + sampleRepo + "'])\n" +
" }\n" +
" dir('other') {\n" +
" checkout([$class: 'MercurialSCM', source: '" + otherRepo + "', clean: true])\n" +
" sh 'echo stuff >> unversioned; wc -l unversioned'\n" +
" }\n" +
" sh 'for f in */*; do echo PRESENT: $f; done'\n" +
" }\n" +
"}"));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
r.assertLogContains("PRESENT: main/file", b);
r.assertLogContains("PRESENT: other/otherfile", b);
r.assertLogContains("1 unversioned", b);
FileUtils.touch(new File(sampleRepo, "file2"));
hg(sampleRepo, "add", "file2");
hg(sampleRepo, "commit", "--message=file2");
FileUtils.touch(new File(otherRepo, "otherfile2"));
hg(otherRepo, "add", "otherfile2");
hg(otherRepo, "commit", "--message=otherfile2");
System.out.println(r.createWebClient().goTo("mercurial/notifyCommit?url=" + URLEncoder.encode(sampleRepo.getAbsolutePath(), "UTF-8"), "text/plain").getWebResponse().getContentAsString());
System.out.println(r.createWebClient().goTo("mercurial/notifyCommit?url=" + URLEncoder.encode(otherRepo.getAbsolutePath(), "UTF-8"), "text/plain").getWebResponse().getContentAsString());
r.waitUntilNoActivity();
FileUtils.copyFile(p.getSCMTrigger().getLogFile(), System.out);
b = p.getLastBuild();
assertEquals(2, b.number);
r.assertLogContains("PRESENT: main/file2", b);
r.assertLogContains("PRESENT: other/otherfile2", b);
r.assertLogContains("1 unversioned", b);
Iterator<? extends SCM> scms = p.getSCMs().iterator();
assertTrue(scms.hasNext());
assertEquals(sampleRepo.getAbsolutePath(), ((MercurialSCM) scms.next()).getSource());
assertTrue(scms.hasNext());
assertEquals(otherRepo.getAbsolutePath(), ((MercurialSCM) scms.next()).getSource());
assertFalse(scms.hasNext());