/** * Tests the "URL@HEAD" format in the SVN URL */ @Test public void headRevisionCheckout() throws Exception { File testRepo = new CopyExisting(getClass().getResource("two-revisions.zip")).allocate(); SubversionSCM scm = new SubversionSCM("file://" + testRepo.toURI().toURL().getPath() + "@HEAD"); FreeStyleProject p = r.createFreeStyleProject(); p.setScm(scm); FreeStyleBuild b = p.scheduleBuild2(0, new Cause.UserIdCause()).get(); System.out.println(b.getLog(LOG_LIMIT)); r.assertLogContains("At revision 2", b); r.assertBuildStatus(Result.SUCCESS,b); }
@Test public void customCacheLocationFromSlave() throws Exception { FreeStyleProject p = j.createFreeStyleProject(); p.setScm(new MercurialSCM(CACHING_INSTALLATION, repo.getPath(), null, null, null, null, false)); p.setAssignedNode(j.createOnlineSlave()); m.hg(repo, "init"); m.touchAndCommit(repo, "a"); String log = m.buildAndCheck(p, "a"); Pattern pattern = Pattern.compile("hg clone .*custom-cache-dir"); Assert.assertTrue(pattern.matcher(log).find()); }
/** * Manufactures commits including metadata * @return */ private void createWorkingCopy(SubversionSCM scm) throws Exception { FreeStyleProject forCommit = r.createFreeStyleProject(); forCommit.setScm(scm); forCommit.setAssignedLabel(r.jenkins.getSelfLabel()); FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); workingcopy = b.getWorkspace(); }
private int checkoutWithFormat(int format) throws Exception { super.configureSvnWorkspaceFormat(format); FreeStyleProject project = r.jenkins.createProject(FreeStyleProject.class, "svntest" + format); SubversionSCM subversionSCM = new SubversionSCM("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant"); project.setScm(subversionSCM); r.assertBuildStatusSuccess(project.scheduleBuild2(0)); // Create a status client and get the working copy format. SVNClientManager testWCVerseion = SVNClientManager.newInstance(null, "testWCVerseion", null); File path = new File(project.getWorkspace().getRemote()); return testWCVerseion.getStatusClient().doStatus(path, true).getWorkingCopyFormat(); } }
private FreeStyleProject createPostCommitTriggerJob() throws Exception { // Disable crumbs because HTMLUnit refuses to mix request bodies with // request parameters r.jenkins.setCrumbIssuer(null); FreeStyleProject p = r.createFreeStyleProject(); String url = "https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant"; SCMTrigger trigger = new SCMTrigger("0 */6 * * *"); p.setScm(new SubversionSCM(url)); p.addTrigger(trigger); trigger.start(p, true); return p; }
@Bug(11460) @Test public void trailingUrlWhitespace() throws Exception { FreeStyleProject p = j.createFreeStyleProject(); p.setScm(new MercurialSCM(hgInstallation(), repo.getPath() + " ", null, null, null, null, false)); m.hg(repo, "init"); m.touchAndCommit(repo, "dir1/f1"); AbstractBuild<?, ?> b = p.scheduleBuild2(0).get(); assertEquals(Result.SUCCESS, b.getResult()); }
@Issue("JENKINS-7944") @Test public void configRoundtrip2() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); SubversionSCM scm = new SubversionSCM( Arrays.asList( new ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/testSubversionExclusion", "")), new UpdateUpdater(),null,null,null,null,null,null); p.setScm(scm); r.configRoundtrip((Item)p); verify(scm,(SubversionSCM)p.getScm()); }
/** * Manufactures commits by adding files in the given names. */ private void createCommit(SubversionSCM scm, String... paths) throws Exception { FreeStyleProject forCommit = r.createFreeStyleProject(); forCommit.setScm(scm); forCommit.setAssignedLabel(r.jenkins.getSelfLabel()); FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject)null); List<File> added = new ArrayList<>(); for (String path : paths) { FilePath newFile = b.getWorkspace().child(path); added.add(new File(newFile.getRemote())); if (!newFile.exists()) { newFile.touch(System.currentTimeMillis()); svnm.getWCClient().doAdd(new File(newFile.getRemote()),false,false,false, SVNDepth.INFINITY, false,false); } else newFile.write("random content","UTF-8"); } SVNCommitClient cc = svnm.getCommitClient(); cc.doCommit(added.toArray(new File[added.size()]),false,"added",null,null,false,false,SVNDepth.EMPTY); }
private FreeStyleProject createPostCommitTriggerJobMultipleSvnLocations() throws Exception { // Disable crumbs because HTMLUnit refuses to mix request bodies with // request parameters r.jenkins.setCrumbIssuer(null); FreeStyleProject p = r.createFreeStyleProject(); String[] urls = new String[] {"https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant", "https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-maven/"}; p.setScm(new SubversionSCM(urls, new String[] {"", ""})); SCMTrigger trigger = new SCMTrigger("0 */6 * * *"); p.addTrigger(trigger); trigger.start(p, true); return p; }
/** * Used for experimenting the memory leak problem. * This test by itself doesn't detect that, but I'm leaving it in anyway. */ @Issue("JENKINS-8061") @Test public void pollingLeak() throws Exception { Proc p = runSvnServe(getClass().getResource("small.zip")); try { FreeStyleProject b = r.createFreeStyleProject(); b.setScm(new SubversionSCM("svn://localhost/")); b.setAssignedNode(r.createSlave()); r.assertBuildStatusSuccess(b.scheduleBuild2(0)); b.poll(new StreamTaskListener(System.out,Charset.defaultCharset())); } finally { p.kill(); } }
@Bug(20186) @Test public void configureBrowser() throws Exception { FreeStyleProject p = j.createFreeStyleProject(); p.setScm(new MercurialSCM(null, "https://host/repo", null, null, null, new HgWeb("https://host/repo"), false, null)); j.configRoundtrip(p); assertEquals("https://host/repo/", ((MercurialSCM) p.getScm()).getBrowser().getUrl().toString()); }
private void invokeTestPollingExternalsForFile() throws Exception { // trunk has svn:externals="^/vendor/target.txt target.txt" File repo = new CopyExisting(getClass().getResource("JENKINS-20165.zip")).allocate(); String path = "file://" + repo.toURI().toURL().getPath(); SubversionSCM scm = new SubversionSCM(path + "trunk"); // first checkout FreeStyleProject p = r.createFreeStyleProject(); p.setScm(scm); p.setAssignedLabel(r.createSlave().getSelfLabel()); r.assertBuildStatusSuccess(p.scheduleBuild2(0).get()); // update target.txt in vendor SubversionSCM vendor = new SubversionSCM(path + "vendor"); createWorkingCopy(vendor); changeFiles("target.txt"); commitWorkingCopy("update"); // should detect change assertTrue(p.poll(StreamTaskListener.fromStdout()).hasChanges()); } }
public void testSwitchingFromSharedToCached() throws Exception { FreeStyleProject p = j.createFreeStyleProject(); p.setScm(new MercurialSCM(sharingInstallation, repo.getPath(), null, null, null, null, false)); m.hg(repo, "init"); m.touchAndCommit(repo, "a"); m.buildAndCheck(p, "a"); assertTrue(p.getSomeWorkspace().child(".hg").child("sharedpath") .exists()); p.setScm(new MercurialSCM(cachingInstallation, repo.getPath(), null, null, null, null, false)); m.touchAndCommit(repo, "b"); m.buildAndCheck(p, "b"); assertFalse(p.getSomeWorkspace().child(".hg").child("sharedpath") .exists()); } }
/** * Makes sure the symbolic link is checked out correctly. There seems to be */ @Issue("JENKINS-3904") @Test public void symbolicLinkCheckout() throws Exception { // Only perform if symlink behavior is enabled if (!"true".equals(System.getProperty("svnkit.symlinks"))) { return; } FreeStyleProject p = r.createFreeStyleProject(); p.setScm(new SubversionSCM("https://svn.jenkins-ci.org/trunk/hudson/test-projects/issue-3904")); FreeStyleBuild b = p.scheduleBuild2(0, new Cause.UserIdCause()).get(); File source = new File(b.getWorkspace().getRemote() + "/readme.txt"); File linked = new File(b.getWorkspace().getRemote() + "/linked.txt"); assertEquals("Files '" + source + "' and '" + linked + "' are not identical from user view.", readFileAsString(source), readFileAsString(linked)); }
@Bug(13174) @Test public void pollingIgnoresMetaFiles() throws Exception { FreeStyleProject p = j.createFreeStyleProject(); p.setScm(new MercurialSCM(hgInstallation(), repo.getPath(), null, null, null, null, false)); m.hg(repo, "init"); m.touchAndCommit(repo, "f"); m.buildAndCheck(p, "f"); m.hg(repo, "tag", "mystuff"); assertEquals(PollingResult.Change.INSIGNIFICANT, m.pollSCMChanges(p).change); }
new UpdateUpdater(), null, "/z.*", "", "", "", "", false, shouldFilterLog, null); FreeStyleProject p = r.createFreeStyleProject(String.format("testFilterChangelog-%s", shouldFilterLog)); p.setScm(scm); r.assertBuildStatusSuccess(p.scheduleBuild2(0).get()); p.poll(r.createTaskListener()).hasChanges()); AbstractBuild build = p.scheduleBuild2(0).get(); r.assertBuildStatusSuccess(build); boolean ignored = true, included = false;
@Issue("JENKINS-1379") @Test public void superUserForAllRepos() throws Exception { Proc p = runSvnServe(getClass().getResource("HUDSON-1379.zip")); try { SystemCredentialsProvider.getInstance().setDomainCredentialsMap(Collections.singletonMap(Domain.global(), Arrays.<Credentials>asList( new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "1-alice", null, "alice","alice") ) )); FreeStyleProject b = r.createFreeStyleProject(); b.setScm(new SubversionSCM("svn://localhost/bob")); FreeStyleProject c = r.createFreeStyleProject(); c.setScm(new SubversionSCM("svn://localhost/charlie")); // should fail without a credential r.assertBuildStatus(Result.FAILURE,b.scheduleBuild2(0).get()); r.assertBuildStatus(Result.FAILURE,c.scheduleBuild2(0).get()); b.setScm(new SubversionSCM("svn://localhost/bob", "1-alice", ".")); c.setScm(new SubversionSCM("svn://localhost/charlie", "1-alice", ".")); // but with the super user credential both should work now r.buildAndAssertSuccess(b); r.buildAndAssertSuccess(c); } finally { p.kill(); } }
@Issue("JENKINS-9143") @Test public void checkEmptyRemoteRemoved() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); List<ModuleLocation> locs = new ArrayList<>(); locs.add(new ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/testSubversionExclusion", "c")); locs.add(new ModuleLocation("", "d")); locs.add(new ModuleLocation(" ", "e")); SubversionSCM scm = new SubversionSCM( locs, new UpdateUpdater(), new Sventon(new URL("http://www.sun.com/"), "test"), "exclude", "user", "revprop", "excludeMessage",null); p.setScm(scm); r.submit(r.createWebClient().getPage(p, "configure").getFormByName("config")); ModuleLocation[] ml = ((SubversionSCM) p.getScm()).getLocations(); assertEquals(1, ml.length); assertEquals("https://svn.jenkins-ci.org/trunk/hudson/test-projects/testSubversionExclusion", ml[0].remote); }
@Bug(12829) @Test public void nonExistingBranchesDontGenerateMercurialTagActionsInTheBuild() throws Exception { AbstractBuild<?, ?> b; FreeStyleProject p = j.createFreeStyleProject(); p.setScm(new MercurialSCM(hgInstallation(), repo.getPath(), "non-existing-branch", null, null, null, false)); m.hg(repo, "init"); m.touchAndCommit(repo, "dir1/f1"); b = p.scheduleBuild2(0).get(); for (Action action : b.getActions()) { if (action instanceof MercurialTagAction) { fail("There should not be any MercurialTagAction"); } } }
@Bug(10706) @Test public void testGetBranchFromTag() throws Exception { initRepoWithTag(); FreeStyleProject p = j.createFreeStyleProject(); p.setScm(new MercurialSCM(hgInstallation(), repo.getPath(), MercurialSCM.RevisionType.TAG, "release", null, null, null, false, null)); FreeStyleBuild b = j.buildAndAssertSuccess(p); MercurialTagAction action = b.getAction(MercurialTagAction.class); assertNotNull(action); assertEquals("stable", action.getBranch()); assertEquals("stable", b.getEnvironment().get("MERCURIAL_REVISION_BRANCH")); }