Search in sources :

Example 31 with ScmTag

use of org.apache.maven.scm.ScmTag 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)

Example 32 with ScmTag

use of org.apache.maven.scm.ScmTag in project maven-plugins by apache.

the class SvnInfoCommandExpanded method createTagCommandLine.

// set scope to protected to allow test to call it directly
protected static Commandline createTagCommandLine(final SvnScmProviderRepository repository, final ScmFileSet fileSet, final String tag, final boolean recursive, final String revision) {
    Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository);
    cl.createArg().setValue("info");
    if (recursive) {
        cl.createArg().setValue("--recursive");
    }
    if (StringUtils.isNotEmpty(revision)) {
        cl.createArg().setValue("-r");
        cl.createArg().setValue(revision);
    }
    Iterator<File> it = fileSet.getFileList().iterator();
    if (!it.hasNext()) {
        String tagUrl = SvnTagBranchUtils.resolveTagUrl(repository, new ScmTag(tag));
        cl.createArg().setValue(SvnCommandUtils.fixUrl(tagUrl, repository.getUser()));
    } else {
        while (it.hasNext()) {
            File file = it.next();
            if (repository == null) {
                cl.createArg().setValue(file.getPath());
            } else {
                // Note: this currently assumes you have the tag base checked out too
                String tagUrl = SvnTagBranchUtils.resolveTagUrl(repository, new ScmTag(tag)) + "/" + file.getPath().replace('\\', '/');
                cl.createArg().setValue(SvnCommandUtils.fixUrl(tagUrl, repository.getUser()));
            }
        }
    }
    return cl;
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) ScmTag(org.apache.maven.scm.ScmTag) File(java.io.File)

Aggregations

ScmTag (org.apache.maven.scm.ScmTag)32 File (java.io.File)17 ScmFileSet (org.apache.maven.scm.ScmFileSet)17 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)9 Commandline (org.codehaus.plexus.util.cli.Commandline)9 Test (org.junit.Test)9 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)8 CommandParameters (org.apache.maven.scm.CommandParameters)7 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)7 ExportScmResult (org.apache.maven.scm.command.export.ExportScmResult)6 ScmBranch (org.apache.maven.scm.ScmBranch)5 ScmRepository (org.apache.maven.scm.repository.ScmRepository)5 ScmException (org.apache.maven.scm.ScmException)4 SvnScmProviderRepository (org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository)4 ScmFile (org.apache.maven.scm.ScmFile)3 ScmManager (org.apache.maven.scm.manager.ScmManager)3 SimpleDateFormat (java.text.SimpleDateFormat)2 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)2 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)2 SvnCommandLineUtils (org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils)2