Skip to content

Commit e0cb1f4

Browse files
authored
Merge pull request #314 from jglick/subversion
Remove `subversion` test dep
2 parents 3479e8f + 4dce43d commit e0cb1f4

4 files changed

Lines changed: 11 additions & 169 deletions

File tree

pom.xml

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,20 @@ THE SOFTWARE.
6363
</pluginRepositories>
6464
<properties>
6565
<changelist>999999-SNAPSHOT</changelist>
66-
<jenkins.version>2.454</jenkins.version>
66+
<jenkins.baseline>2.462</jenkins.baseline>
67+
<jenkins.version>${jenkins.baseline}</jenkins.version>
6768
<no-test-jar>false</no-test-jar>
6869
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
6970
</properties>
7071
<dependencyManagement>
7172
<dependencies>
7273
<dependency>
7374
<groupId>io.jenkins.tools.bom</groupId>
74-
<artifactId>bom-2.440.x</artifactId>
75-
<version>2746.vb_79a_1d3e7b_c8</version>
75+
<artifactId>bom-${jenkins.baseline}.x</artifactId>
76+
<version>3221.ve8f7b_fdd149d</version>
7677
<scope>import</scope>
7778
<type>pom</type>
7879
</dependency>
79-
<!-- TODO until in BOM -->
80-
<dependency>
81-
<groupId>org.jenkins-ci.plugins</groupId>
82-
<artifactId>cloudbees-folder</artifactId>
83-
<version>6.919.va_e17e72383f5</version>
84-
</dependency>
8580
</dependencies>
8681
</dependencyManagement>
8782
<dependencies>
@@ -173,39 +168,12 @@ THE SOFTWARE.
173168
<artifactId>git</artifactId>
174169
<scope>test</scope>
175170
</dependency>
176-
<dependency>
177-
<groupId>org.jenkins-ci.plugins</groupId>
178-
<artifactId>subversion</artifactId>
179-
<scope>test</scope>
180-
<exclusions>
181-
<exclusion>
182-
<groupId>org.apache.sshd</groupId>
183-
<artifactId>sshd-common</artifactId>
184-
</exclusion>
185-
<exclusion>
186-
<groupId>org.apache.sshd</groupId>
187-
<artifactId>sshd-core</artifactId>
188-
</exclusion>
189-
</exclusions>
190-
</dependency>
191171
<dependency>
192172
<groupId>org.jenkins-ci.plugins</groupId>
193173
<artifactId>git</artifactId>
194174
<classifier>tests</classifier>
195175
<scope>test</scope>
196176
</dependency>
197-
<dependency>
198-
<groupId>org.jenkins-ci.plugins</groupId>
199-
<artifactId>subversion</artifactId>
200-
<classifier>tests</classifier>
201-
<scope>test</scope>
202-
</dependency>
203-
<dependency>
204-
<groupId>org.tmatesoft.svnkit</groupId>
205-
<artifactId>svnkit-cli</artifactId>
206-
<version>1.10.10</version>
207-
<scope>test</scope>
208-
</dependency>
209177
<dependency>
210178
<groupId>org.jenkins-ci.plugins.workflow</groupId>
211179
<artifactId>workflow-job</artifactId>

src/main/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinder.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package org.jenkinsci.plugins.workflow.multibranch;
2626

2727
import edu.umd.cs.findbugs.annotations.NonNull;
28+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2829
import hudson.Extension;
2930
import hudson.Functions;
3031
import hudson.MarkupText;
@@ -54,14 +55,18 @@
5455
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
5556
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
5657
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
58+
import org.kohsuke.accmod.Restricted;
59+
import org.kohsuke.accmod.restrictions.NoExternalUse;
5760

5861
/**
5962
* Checks out the desired version of the script referred to by scriptPath.
6063
*/
61-
class SCMBinder extends FlowDefinition {
64+
@Restricted(NoExternalUse.class) // just tests
65+
public class SCMBinder extends FlowDefinition {
6266

6367
/** Kill switch for JENKINS-33273 in case of problems. */
64-
static /* not final */ boolean USE_HEAVYWEIGHT_CHECKOUT = Boolean.getBoolean(SCMBinder.class.getName() + ".USE_HEAVYWEIGHT_CHECKOUT"); // TODO 2.4+ use SystemProperties
68+
@SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "Just for scripting.")
69+
public static boolean USE_HEAVYWEIGHT_CHECKOUT = Boolean.getBoolean(SCMBinder.class.getName() + ".USE_HEAVYWEIGHT_CHECKOUT"); // TODO 2.4+ use SystemProperties
6570
private String scriptPath = WorkflowBranchProjectFactory.SCRIPT;
6671

6772
public Object readResolve() {

src/test/java/org/jenkinsci/plugins/workflow/multibranch/ReadTrustedStepTest.java

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626

2727
import hudson.Functions;
2828
import hudson.model.Result;
29-
import hudson.scm.SubversionSCM;
30-
import java.io.File;
31-
import java.nio.charset.StandardCharsets;
3229
import jenkins.branch.BranchSource;
3330
import jenkins.plugins.git.GitSampleRepoRule;
3431
import jenkins.plugins.git.GitStep;
@@ -47,25 +44,15 @@
4744
import java.nio.file.Files;
4845
import java.nio.file.Path;
4946
import java.nio.file.Paths;
50-
import jenkins.plugins.git.GitSCMSource;
51-
import jenkins.scm.impl.subversion.SubversionSCMSource;
52-
import jenkins.scm.impl.subversion.SubversionSampleRepoRule;
53-
import org.apache.commons.io.FileUtils;
54-
import org.junit.Ignore;
5547
import org.jvnet.hudson.test.FlagRule;
5648

57-
import static org.hamcrest.MatcherAssert.assertThat;
58-
import static org.hamcrest.Matchers.equalTo;
59-
import static org.hamcrest.Matchers.not;
60-
import static org.hamcrest.io.FileMatchers.anExistingFile;
6149
import static org.junit.Assume.assumeFalse;
6250

6351
public class ReadTrustedStepTest {
6452

6553
@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
6654
@Rule public JenkinsRule r = new JenkinsRule();
6755
@Rule public GitSampleRepoRule sampleRepo = new GitSampleRepoRule();
68-
@Rule public SubversionSampleRepoRule sampleRepoSvn = new SubversionSampleRepoRule();
6956
@Rule public FlagRule<Boolean> heavyweightCheckoutFlag = new FlagRule<>(() -> SCMBinder.USE_HEAVYWEIGHT_CHECKOUT, v -> { SCMBinder.USE_HEAVYWEIGHT_CHECKOUT = v; });
7057

7158
@Test public void smokes() throws Exception {
@@ -305,76 +292,4 @@ public void symlinksInNonMultibranchCannotEscapeWorkspaceContextViaReadTrusted()
305292
r.assertLogContains("master.key references a file that is not inside " + r.jenkins.getWorkspaceFor(p), run);
306293
}
307294

308-
@Ignore("There are two checkouts, one from CpsScmFlowDefinition via SCMBinder and one from ReadTrustedStep. Fixing the former requires an updated version of workflow-cps.")
309-
@Issue("SECURITY-2463")
310-
@Test public void multibranchCheckoutDirectoriesAreNotReusedByDifferentScms() throws Exception {
311-
SCMBinder.USE_HEAVYWEIGHT_CHECKOUT = true;
312-
assumeFalse(Functions.isWindows()); // Checkout hook is not cross-platform.
313-
sampleRepo.init();
314-
sampleRepo.git("checkout", "-b", "trunk"); // So we end up using the same project for both SCMs.
315-
sampleRepo.write("Jenkinsfile", "echo('git library'); readTrusted('Jenkinsfile')");
316-
sampleRepo.git("add", "Jenkinsfile");
317-
sampleRepo.git("commit", "--message=init");
318-
sampleRepoSvn.init();
319-
sampleRepoSvn.write("Jenkinsfile", "echo('svn library'); readTrusted('Jenkinsfile')");
320-
// Copy .git folder from the Git repo into the SVN repo as data.
321-
File gitDirInSvnRepo = new File(sampleRepoSvn.wc(), ".git");
322-
FileUtils.copyDirectory(new File(sampleRepo.getRoot(), ".git"), gitDirInSvnRepo);
323-
String jenkinsRootDir = r.jenkins.getRootDir().toString();
324-
// Add a Git post-checkout hook to the .git folder in the SVN repo.
325-
Path postCheckoutHook = gitDirInSvnRepo.toPath().resolve("hooks/post-checkout");
326-
// Always create hooks directory for compatibility with https://github.com/jenkinsci/git-plugin/pull/1207.
327-
Files.createDirectories(postCheckoutHook.getParent());
328-
Files.write(postCheckoutHook, ("#!/bin/sh\ntouch '" + jenkinsRootDir + "/hook-executed'\n").getBytes(StandardCharsets.UTF_8));
329-
sampleRepoSvn.svnkit("add", sampleRepoSvn.wc() + "/Jenkinsfile");
330-
sampleRepoSvn.svnkit("add", sampleRepoSvn.wc() + "/.git");
331-
sampleRepoSvn.svnkit("propset", "svn:executable", "ON", sampleRepoSvn.wc() + "/.git/hooks/post-checkout");
332-
sampleRepoSvn.svnkit("commit", "--message=init", sampleRepoSvn.wc());
333-
// Run a build using the SVN repo.
334-
WorkflowMultiBranchProject mp = r.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
335-
mp.getSourcesList().add(new BranchSource(new SubversionSCMSource("", sampleRepoSvn.prjUrl())));
336-
WorkflowJob p = WorkflowMultiBranchProjectTest.scheduleAndFindBranchProject(mp, "trunk");
337-
r.waitUntilNoActivity();
338-
// Run a build using the Git repo. It should be checked out to a different directory than the SVN repo.
339-
mp.getSourcesList().clear();
340-
mp.getSourcesList().add(new BranchSource(new GitSCMSource("", sampleRepo.toString(), "", "*", "", false)));
341-
WorkflowMultiBranchProjectTest.scheduleAndFindBranchProject(mp, "trunk");
342-
r.waitUntilNoActivity();
343-
assertThat(p.getLastBuild().getNumber(), equalTo(2));
344-
assertThat(new File(r.jenkins.getRootDir(), "hook-executed"), not(anExistingFile()));
345-
}
346-
347-
@Ignore("There are two checkouts, one from CpsScmFlowDefinition and one from ReadTrustedStep. Fixing the former requires an updated version of workflow-cps.")
348-
@Issue("SECURITY-2463")
349-
@Test public void checkoutDirectoriesAreNotReusedByDifferentScms() throws Exception {
350-
SCMBinder.USE_HEAVYWEIGHT_CHECKOUT = true;
351-
assumeFalse(Functions.isWindows()); // Checkout hook is not cross-platform.
352-
sampleRepo.init();
353-
sampleRepo.write("Jenkinsfile", "echo('git library'); readTrusted('Jenkinsfile')");
354-
sampleRepo.git("add", "Jenkinsfile");
355-
sampleRepo.git("commit", "--message=init");
356-
sampleRepoSvn.init();
357-
sampleRepoSvn.write("Jenkinsfile", "echo('subversion library'); readTrusted('Jenkinsfile')");
358-
// Copy .git folder from the Git repo into the SVN repo as data.
359-
File gitDirInSvnRepo = new File(sampleRepoSvn.wc(), ".git");
360-
FileUtils.copyDirectory(new File(sampleRepo.getRoot(), ".git"), gitDirInSvnRepo);
361-
String jenkinsRootDir = r.jenkins.getRootDir().toString();
362-
// Add a Git post-checkout hook to the .git folder in the SVN repo.
363-
Path postCheckoutHook = gitDirInSvnRepo.toPath().resolve("hooks/post-checkout");
364-
// Always create hooks directory for compatibility with https://github.com/jenkinsci/git-plugin/pull/1207.
365-
Files.createDirectories(postCheckoutHook.getParent());
366-
Files.write(postCheckoutHook, ("#!/bin/sh\ntouch '" + jenkinsRootDir + "/hook-executed'\n").getBytes(StandardCharsets.UTF_8));
367-
sampleRepoSvn.svnkit("add", sampleRepoSvn.wc() + "/Jenkinsfile");
368-
sampleRepoSvn.svnkit("add", sampleRepoSvn.wc() + "/.git");
369-
sampleRepoSvn.svnkit("propset", "svn:executable", "ON", sampleRepoSvn.wc() + "/.git/hooks/post-checkout");
370-
sampleRepoSvn.svnkit("commit", "--message=init", sampleRepoSvn.wc());
371-
// Run a build using the SVN repo.
372-
WorkflowJob p = r.createProject(WorkflowJob.class);
373-
p.setDefinition(new CpsScmFlowDefinition(new SubversionSCM(sampleRepoSvn.trunkUrl()), "Jenkinsfile"));
374-
r.buildAndAssertSuccess(p);
375-
// Run a build using the Git repo. It should be checked out to a different directory than the SVN repo.
376-
p.setDefinition(new CpsScmFlowDefinition(new GitStep(sampleRepo.toString()).createSCM(), "Jenkinsfile"));
377-
WorkflowRun b2 = r.buildAndAssertSuccess(p);
378-
assertThat(new File(r.jenkins.getRootDir(), "hook-executed"), not(anExistingFile()));
379-
}
380295
}

src/test/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinderTest.java

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@
4949
import jenkins.scm.api.SCMRevision;
5050
import jenkins.scm.api.SCMRevisionAction;
5151
import jenkins.scm.api.SCMSourceDescriptor;
52-
import jenkins.scm.impl.subversion.SubversionSCMFileSystem;
53-
import jenkins.scm.impl.subversion.SubversionSCMSource;
5452
import static org.hamcrest.Matchers.*;
5553

56-
import jenkins.scm.impl.subversion.SubversionSampleRepoRule;
5754
import org.acegisecurity.Authentication;
5855
import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval;
5956
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
@@ -72,7 +69,6 @@ public class SCMBinderTest {
7269
@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
7370
@Rule public JenkinsRule r = new JenkinsRule();
7471
@Rule public GitSampleRepoRule sampleGitRepo = new GitSampleRepoRule();
75-
@Rule public SubversionSampleRepoRule sampleSvnRepo = new SubversionSampleRepoRule();
7672

7773
@Test public void exactRevisionGit() throws Exception {
7874
sampleGitRepo.init();
@@ -131,48 +127,6 @@ public static void assertRevisionAction(WorkflowRun build) {
131127
}
132128
}
133129

134-
static {
135-
System.setProperty(SubversionSCMFileSystem.DISABLE_PROPERTY, "true");
136-
}
137-
@Test public void exactRevisionSubversion() throws Exception {
138-
sampleSvnRepo.init();
139-
ScriptApproval sa = ScriptApproval.get();
140-
sa.approveSignature("staticField hudson.model.Items XSTREAM2");
141-
sa.approveSignature("method com.thoughtworks.xstream.XStream toXML java.lang.Object");
142-
sampleSvnRepo.write("Jenkinsfile", "echo hudson.model.Items.XSTREAM2.toXML(scm); semaphore 'wait'; node {checkout scm; echo readFile('file')}");
143-
sampleSvnRepo.write("file", "initial content");
144-
sampleSvnRepo.svnkit("add", sampleSvnRepo.wc() + "/Jenkinsfile");
145-
sampleSvnRepo.svnkit("commit", "--message=flow", sampleSvnRepo.wc());
146-
WorkflowMultiBranchProject mp = r.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
147-
mp.getSourcesList().add(new BranchSource(new SubversionSCMSource(null, sampleSvnRepo.prjUrl())));
148-
WorkflowJob p = WorkflowMultiBranchProjectTest.scheduleAndFindBranchProject(mp, "trunk");
149-
SemaphoreStep.waitForStart("wait/1", null);
150-
WorkflowRun b1 = p.getLastBuild();
151-
assertNotNull(b1);
152-
assertEquals(1, b1.getNumber());
153-
sampleSvnRepo.write("Jenkinsfile", "node {checkout scm; echo readFile('file').toUpperCase()}");
154-
sampleSvnRepo.write("file", "subsequent content");
155-
sampleSvnRepo.svnkit("commit", "--message=tweaked", sampleSvnRepo.wc());
156-
SemaphoreStep.success("wait/1", null);
157-
WorkflowRun b2 = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
158-
assertEquals(2, b2.getNumber());
159-
r.assertLogContains("initial content", r.waitForCompletion(b1));
160-
r.assertLogContains("SUBSEQUENT CONTENT", b2);
161-
List<ChangeLogSet<? extends ChangeLogSet.Entry>> changeSets = b2.getChangeSets();
162-
/* TODO JENKINS-29326 analogue: currently 2 (they are the same):
163-
assertEquals(1, changeSets.size());
164-
*/
165-
ChangeLogSet<? extends ChangeLogSet.Entry> changeSet = changeSets.get(0);
166-
assertEquals(b2, changeSet.getRun());
167-
assertEquals("svn", changeSet.getKind());
168-
Iterator<? extends ChangeLogSet.Entry> iterator = changeSet.iterator();
169-
assertTrue(iterator.hasNext());
170-
ChangeLogSet.Entry entry = iterator.next();
171-
assertEquals("tweaked", entry.getMsg());
172-
assertEquals("[Jenkinsfile, file]", new TreeSet<>(entry.getAffectedPaths()).toString());
173-
assertFalse(iterator.hasNext());
174-
}
175-
176130
@Test public void deletedJenkinsfile() throws Exception {
177131
sampleGitRepo.init();
178132
sampleGitRepo.write("Jenkinsfile", "node { echo 'Hello World' }");

0 commit comments

Comments
 (0)