From e5c5804272c8b02f7205a80c3bbecaad41b69a32 Mon Sep 17 00:00:00 2001 From: Cathy Chan Date: Fri, 6 May 2022 18:49:00 -0400 Subject: [PATCH] Delete parent directory to force clone --- .../jenkins/tools/test/hook/AbstractMultiParentHook.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/AbstractMultiParentHook.java b/plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/AbstractMultiParentHook.java index 457d6befa..aa479cf3f 100644 --- a/plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/AbstractMultiParentHook.java +++ b/plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/AbstractMultiParentHook.java @@ -2,6 +2,7 @@ import hudson.model.UpdateSite; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -15,6 +16,7 @@ import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.repository.ScmRepositoryException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.codehaus.plexus.util.FileUtils; import org.jenkins.tools.test.PluginCompatTester; import org.jenkins.tools.test.SCMManagerFactory; import org.jenkins.tools.test.model.PluginCompatTesterConfig; @@ -80,7 +82,7 @@ public Map action(Map moreInfo) throws Exception } private void cloneFromSCM(UpdateSite.Plugin currentPlugin, File parentPath, String scmTag, String url, String fallbackGitHubOrganization) - throws ComponentLookupException, ScmRepositoryException, NoSuchScmProviderException, ScmException { + throws ComponentLookupException, ScmRepositoryException, NoSuchScmProviderException, ScmException, IOException { List connectionURLs = new ArrayList(); connectionURLs.add(url); @@ -97,6 +99,9 @@ private void cloneFromSCM(UpdateSite.Plugin currentPlugin, File parentPath, Stri connectionURL = connectionURL.replace("git://", "https://"); // See: https://github.blog/2021-09-01-improving-git-protocol-security-github/ } System.out.println("Checking out from SCM connection URL: " + connectionURL + " (" + getParentProjectName() + "-" + currentPlugin.version + ") at tag " + scmTag); + if (parentPath.isDirectory()) { + FileUtils.deleteDirectory(parentPath); + } repository = scmManager.makeScmRepository(connectionURL); CheckOutScmResult result = scmManager.checkOut(repository, new ScmFileSet(parentPath), new ScmTag(scmTag)); if(result.isSuccess()){