Search in sources :

Example 56 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project plugin-compat-tester by jenkinsci.

the class PluginCompatTester method cloneFromSCM.

private void cloneFromSCM(String connectionUrl, String name, String version, File checkoutDirectory) throws ComponentLookupException, ScmException {
    System.out.println("Checking out from SCM connection URL : " + connectionUrl + " (" + name + "-" + version + ")");
    ScmManager scmManager = SCMManagerFactory.getInstance().createScmManager();
    ScmRepository repository = scmManager.makeScmRepository(connectionUrl);
    CheckOutScmResult result = scmManager.checkOut(repository, new ScmFileSet(checkoutDirectory), new ScmTag(name + "-" + version));
    if (!result.isSuccess()) {
        throw new RuntimeException(result.getProviderMessage() + " || " + result.getCommandOutput());
    }
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) ScmManager(org.apache.maven.scm.manager.ScmManager) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Example 57 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project plugin-compat-tester by jenkinsci.

the class AbstractMultiParentHook method action.

public Map<String, Object> action(Map<String, Object> moreInfo) throws Exception {
    PluginCompatTesterConfig config = (PluginCompatTesterConfig) moreInfo.get("config");
    UpdateSite.Plugin currentPlugin = (UpdateSite.Plugin) moreInfo.get("plugin");
    // We should not execute the hook if using localCheckoutDir
    boolean shouldExecuteHook = config.getLocalCheckoutDir() == null || !config.getLocalCheckoutDir().exists();
    if (shouldExecuteHook) {
        System.out.println("Executing Hook for " + getParentProjectName());
        // Determine if we need to run the download; only run for first identified plugin in the series
        if (firstRun) {
            System.out.println("Preparing for Multimodule checkout");
            // Checkout to the parent directory. All other processes will be on the child directory
            File parentPath = new File(config.workDirectory.getAbsolutePath() + "/" + getParentFolder());
            System.out.println("Checking out from SCM connection URL: " + getParentUrl() + " (" + getParentProjectName() + "-" + currentPlugin.version + ")");
            ScmManager scmManager = SCMManagerFactory.getInstance().createScmManager();
            ScmRepository repository = scmManager.makeScmRepository(getParentUrl());
            CheckOutScmResult result = scmManager.checkOut(repository, new ScmFileSet(parentPath), new ScmTag(getParentProjectName() + "-" + currentPlugin.version));
            if (!result.isSuccess()) {
                // Throw an exception if there are any download errors.
                throw new RuntimeException(result.getProviderMessage() + "||" + result.getCommandOutput());
            }
        }
        // Checkout already happened, don't run through again
        moreInfo.put("runCheckout", false);
        firstRun = false;
        // Change the "download"" directory; after download, it's simply used for reference
        File childPath = new File(config.workDirectory.getAbsolutePath() + "/" + getParentFolder() + "/" + getPluginFolderName(currentPlugin));
        System.out.println("Child path for " + currentPlugin.getDisplayName() + " " + childPath);
        moreInfo.put("checkoutDir", childPath);
        moreInfo.put("pluginDir", childPath);
    }
    return moreInfo;
}
Also used : PluginCompatTesterConfig(org.jenkins.tools.test.model.PluginCompatTesterConfig) ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) ScmManager(org.apache.maven.scm.manager.ScmManager) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) UpdateSite(hudson.model.UpdateSite) File(java.io.File)

Aggregations

CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)57 File (java.io.File)24 ScmFileSet (org.apache.maven.scm.ScmFileSet)20 ScmFile (org.apache.maven.scm.ScmFile)14 ScmException (org.apache.maven.scm.ScmException)11 ScmTag (org.apache.maven.scm.ScmTag)9 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)9 Commandline (org.codehaus.plexus.util.cli.Commandline)8 Test (org.junit.Test)8 CommandParameters (org.apache.maven.scm.CommandParameters)7 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)7 IOException (java.io.IOException)6 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)6 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)6 ScmManager (org.apache.maven.scm.manager.ScmManager)5 ScmRepository (org.apache.maven.scm.repository.ScmRepository)5 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)5 ArrayList (java.util.ArrayList)4 ScmResult (org.apache.maven.scm.ScmResult)4 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)3