/** * @since 1.34 */ public SubversionChangeLogBuilder(Run<?,?> build, FilePath workspace, @Nonnull SVNRevisionState baseline, EnvVars env, TaskListener listener, SubversionSCM scm) throws IOException { previousRevisions = baseline.revisions; thisRevisions = scm.parseSvnRevisionFile(build); this.listener = listener; this.scm = scm; this.build = build; this.workspace = workspace; this.env = env; }
Map<String,Long> revisions = parseSvnRevisionFile(build); Set<String> knownURLs = revisions.keySet(); if(svnLocations.length==1) {
@SuppressWarnings("deprecation") @Test public void shouldSetEnvironmentVariablesWithSingleSvnModule() throws IOException { // GIVEN an scm with a single module location SubversionSCM scm = mockSCMForBuildEnvVars(); ModuleLocation[] singleLocation = new ModuleLocation[] {new ModuleLocation("/remotepath", "")}; when(scm.getLocations(any(EnvVars.class), any(AbstractBuild.class))).thenReturn(singleLocation); Map<String, Long> revisions = new HashMap<>(); revisions.put("/remotepath", 4711L); when(scm.parseSvnRevisionFile(any(AbstractBuild.class))).thenReturn(revisions); // WHEN envVars are build AbstractBuild<?,?> build = mock(AbstractBuild.class); Map<String, String> envVars = new HashMap<>(); scm.buildEnvVars(build, envVars); // THEN: we have the (legacy) SVN_URL and SVN_REVISION vars assertThat(envVars.get("SVN_URL"), is("/remotepath")); assertThat(envVars.get("SVN_REVISION"), is("4711")); // AND: also the index-based vars assertThat(envVars.get("SVN_URL_1"), is("/remotepath")); assertThat(envVars.get("SVN_REVISION_1"), is("4711")); }
@SuppressWarnings("deprecation") @Test public void shouldSetEnvironmentVariablesWithMultipleSvnModules() throws IOException { // GIVEN an scm with a 2 module locations SubversionSCM scm = mockSCMForBuildEnvVars(); ModuleLocation[] locations = new ModuleLocation[] { new ModuleLocation("/remotepath1", ""), new ModuleLocation("/remotepath2", "")}; when(scm.getLocations(any(EnvVars.class), any(AbstractBuild.class))).thenReturn(locations); Map<String, Long> revisions = new HashMap<>(); revisions.put("/remotepath1", 4711L); revisions.put("/remotepath2", 42L); when(scm.parseSvnRevisionFile(any(AbstractBuild.class))).thenReturn(revisions); // WHEN envVars are build AbstractBuild<?,?> build = mock(AbstractBuild.class); Map<String, String> envVars = new HashMap<>(); scm.buildEnvVars(build, envVars); // THEN: we have the SVN_URL_n and SVN_REVISION_n vars assertThat(envVars.get("SVN_URL_1"), is("/remotepath1")); assertThat(envVars.get("SVN_REVISION_1"), is("4711")); assertThat(envVars.get("SVN_URL_2"), is("/remotepath2")); assertThat(envVars.get("SVN_REVISION_2"), is("42")); }