public static List<ModuleLocation> parse(String[] remoteLocations, String[] localLocations, String[] depthOptions, boolean[] isIgnoreExternals) { List<ModuleLocation> modules = new ArrayList<ModuleLocation>(); if (remoteLocations != null && localLocations != null) { int entries = Math.min(remoteLocations.length, localLocations.length); for (int i = 0; i < entries; i++) { // the remote (repository) location String remoteLoc = Util.nullify(remoteLocations[i]); if (remoteLoc != null) {// null if skipped remoteLoc = Util.removeTrailingSlash(remoteLoc.trim()); modules.add(new ModuleLocation(remoteLoc, Util.nullify(localLocations[i]), depthOptions != null ? depthOptions[i] : null, isIgnoreExternals != null && isIgnoreExternals[i])); } } } return modules; }
@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); }
@Issue("JENKINS-18099") @Test public void globalExclusionRevprop() throws Exception { SubversionSCM scm = new SubversionSCM( Arrays.asList(new SubversionSCM.ModuleLocation("file://some/repo", ".")), new UpdateUpdater(), null, null, null, null, null, null, false); scm.getDescriptor().setGlobalExcludedRevprop("ignoreme"); SVNProperties p = new SVNProperties(); p.put("ignoreme", "*"); Map<String, SVNLogEntryPath> paths = new HashMap<>(); paths.put("/foo", new SVNLogEntryPath("/foo", SVNLogEntryPath.TYPE_MODIFIED, null, -1)); SVNLogEntry e = new SVNLogEntry(paths, 1234L, p, false); SVNLogFilter filter = scm.createSVNLogFilter(); assertFalse(filter.isIncluded(e)); }
@Test public void configRoundtrip() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); SubversionSCM scm = new SubversionSCM( Arrays.asList( new ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/testSubversionExclusion", "c"), new ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/testSubversionExclusion", "d")), 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")); verify(scm,(SubversionSCM)p.getScm()); scm = new SubversionSCM( Arrays.asList( new ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/testSubversionExclusion", "c")), new CheckoutUpdater(),null,"","","","",null); p.setScm(scm); r.submit(r.createWebClient().getPage(p,"configure").getFormByName("config")); verify(scm,(SubversionSCM)p.getScm()); }
@Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void multiModuleEnvironmentVariables() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); ModuleLocation[] locations = { new ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant", null), new ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-maven", null) }; p.setScm(new SubversionSCM(Arrays.asList(locations), new CheckoutUpdater(), null, null, null, null, null, null)); CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder(); p.getBuildersList().add(builder); r.assertBuildStatusSuccess(p.scheduleBuild2(0).get()); assertEquals("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant", builder.getEnvVars().get("SVN_URL_1")); assertEquals("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-maven", builder.getEnvVars().get("SVN_URL_2")); assertEquals(getActualRevision(p.getLastBuild(), "https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant").toString(), builder.getEnvVars().get("SVN_REVISION_1")); assertEquals(getActualRevision(p.getLastBuild(), "https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-maven").toString(), builder.getEnvVars().get("SVN_REVISION_2")); }
public ModuleLocation withLocal(String local) { return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption, cancelProcessOnExternalsFail); }
public ModuleLocation withCancelProcessOnExternalsFailed(boolean cancelProcessOnExternalsFailed) { return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption, cancelProcessOnExternalsFailed); }
public ModuleLocation withIgnoreExternalsOption(boolean ignoreExternalsOption) { return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption, cancelProcessOnExternalsFail); }
@Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void excludeByUser() throws Exception { FreeStyleProject p = r.createFreeStyleProject( "testExcludeByUser" ); p.setScm(new SubversionSCM( Arrays.asList( new ModuleLocation( "https://svn.jenkins-ci.org/trunk/hudson/test-projects/testSubversionExclusions@19438", null )), new UpdateUpdater(), null, "", "dty", "", "", null) ); // Do a build to force the creation of the workspace. This works around // pollChanges returning true when the workspace does not exist. p.scheduleBuild2(0).get(); boolean foundChanges = p.poll(r.createTaskListener()).hasChanges(); assertFalse("Polling found changes that should have been ignored", foundChanges); }
public ModuleLocation withDepthOption(String depthOption) { return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption, cancelProcessOnExternalsFail); }
public ModuleLocation withCredentialsId(String credentialsId) { return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption, cancelProcessOnExternalsFail); }
public ModuleLocation withRemote(String remote) { return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption, cancelProcessOnExternalsFail); }
@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()); }
/** * Expand location value based on environment variables. * * @return Output ModuleLocation expanded according to specified env vars. */ public ModuleLocation getExpandedLocation(EnvVars env) { return new ModuleLocation(env.expand(remote), credentialsId, env.expand(getLocalDir()), getDepthOption(), isIgnoreExternalsOption(), isCancelProcessOnExternalsFail()); }
@Test public void testRevisionInUrlOverridesEverything_HEAD() { UpdateTask updateTask = createUpdateTask(); updateTask.revisions = new RevisionParameterAction(new SubversionSCM.SvnInfo("remote", 4711)); ModuleLocation l = new ModuleLocation("remote@HEAD", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(SVNRevision.HEAD.getName(), revision.getName()); assertEquals(-1L, revision.getNumber()); assertNull(revision.getDate()); }
@Test public void testGetRevisionFromTimestamp() { UpdateTask updateTask = createUpdateTask(); ModuleLocation l = new ModuleLocation("remote", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(NOW, revision.getDate()); assertEquals(-1L, revision.getNumber()); }
@Test public void testRevisionInUrlOverridesEverything() { UpdateTask updateTask = createUpdateTask(); updateTask.revisions = new RevisionParameterAction(new SubversionSCM.SvnInfo("remote", 4711)); ModuleLocation l = new ModuleLocation("remote@12345", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(12345L, revision.getNumber()); assertNull(revision.getDate()); }
@Test public void testRevisionFromRevisionParametersOverrideTimestamp() { UpdateTask updateTask = createUpdateTask(); updateTask.revisions = new RevisionParameterAction(new SubversionSCM.SvnInfo("remote", 4711)); ModuleLocation l = new ModuleLocation("remote", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(4711L, revision.getNumber()); assertNull(revision.getDate()); }
/** * Expand location value based on Build parametric execution. * * @param build Build instance for expanding parameters into their values * @return Output ModuleLocation expanded according to Build parameters * values. */ public ModuleLocation getExpandedLocation(AbstractBuild<?, ?> build) { return new ModuleLocation(getExpandedRemote(build), getLocalDir(), getDepthOption(), isIgnoreExternalsOption()); }
/** * Expand location value based on Build parametric execution. * * @param build Build instance for expanding parameters into their values * @return Output ModuleLocation expanded according to Build parameters * values. */ public ModuleLocation getExpandedLocation(AbstractBuild<?, ?> build) { return new ModuleLocation(getExpandedRemote(build), getLocalDir(), getDepthOption(), isIgnoreExternalsOption()); }