Search in sources :

Example 11 with ScmManager

use of org.apache.maven.scm.manager.ScmManager 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

ScmManager (org.apache.maven.scm.manager.ScmManager)11 ScmFileSet (org.apache.maven.scm.ScmFileSet)8 ScmRepository (org.apache.maven.scm.repository.ScmRepository)8 File (java.io.File)7 ScmFile (org.apache.maven.scm.ScmFile)6 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)5 Date (java.util.Date)3 ScmTag (org.apache.maven.scm.ScmTag)3 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)3 PluginCompatTesterConfig (org.jenkins.tools.test.model.PluginCompatTesterConfig)2 UpdateSite (hudson.model.UpdateSite)1 Plugin (hudson.model.UpdateSite.Plugin)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 Reader (java.io.Reader)1 ChangeSet (org.apache.maven.scm.ChangeSet)1 BlameLine (org.apache.maven.scm.command.blame.BlameLine)1 BlameScmRequest (org.apache.maven.scm.command.blame.BlameScmRequest)1 BlameScmResult (org.apache.maven.scm.command.blame.BlameScmResult)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1