Search in sources :

Example 6 with PluginCompatTesterConfig

use of org.jenkins.tools.test.model.PluginCompatTesterConfig 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

File (java.io.File)6 PluginCompatTesterConfig (org.jenkins.tools.test.model.PluginCompatTesterConfig)6 ScmFileSet (org.apache.maven.scm.ScmFileSet)2 ScmTag (org.apache.maven.scm.ScmTag)2 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)2 ScmManager (org.apache.maven.scm.manager.ScmManager)2 ScmRepository (org.apache.maven.scm.repository.ScmRepository)2 ExternalMavenRunner (org.jenkins.tools.test.maven.ExternalMavenRunner)2 InternalMavenRunner (org.jenkins.tools.test.maven.InternalMavenRunner)2 JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 UpdateSite (hudson.model.UpdateSite)1 Plugin (hudson.model.UpdateSite.Plugin)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Properties (java.util.Properties)1 PomExecutionException (org.jenkins.tools.test.exception.PomExecutionException)1