Search in sources :

Example 21 with HgMaterialConfig

use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.

the class PipelineInstanceModelTest method shouldGetLatestRevisionForMaterial.

@Test
public void shouldGetLatestRevisionForMaterial() {
    HgMaterialConfig hgMaterialConfig = MaterialConfigsMother.hgMaterialConfig();
    assertThat(setUpModificationForHgMaterial().getLatestRevision(hgMaterialConfig).getRevision(), is("a087402bd2a7828a130c1bdf43f2d9ef8f48fd46"));
}
Also used : HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) Test(org.junit.Test)

Example 22 with HgMaterialConfig

use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.

the class HgTestRepo method createMaterialConfig.

public HgMaterialConfig createMaterialConfig(String dest) {
    HgMaterialConfig materialConfig = materialConfig();
    materialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, dest));
    return materialConfig;
}
Also used : HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)

Example 23 with HgMaterialConfig

use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.

the class ConfigConverter method toScmMaterialConfig.

private ScmMaterialConfig toScmMaterialConfig(CRScmMaterial crScmMaterial) {
    String materialName = crScmMaterial.getName();
    if (crScmMaterial instanceof CRGitMaterial) {
        CRGitMaterial git = (CRGitMaterial) crScmMaterial;
        String gitBranch = git.getBranch();
        if (StringUtils.isBlank(gitBranch))
            gitBranch = GitMaterialConfig.DEFAULT_BRANCH;
        GitMaterialConfig gitConfig = new GitMaterialConfig(git.getUrl(), gitBranch, git.shallowClone());
        setCommonMaterialMembers(gitConfig, crScmMaterial);
        setCommonScmMaterialMembers(gitConfig, git);
        return gitConfig;
    } else if (crScmMaterial instanceof CRHgMaterial) {
        CRHgMaterial hg = (CRHgMaterial) crScmMaterial;
        return new HgMaterialConfig(new HgUrlArgument(hg.getUrl()), hg.isAutoUpdate(), toFilter(crScmMaterial), false, hg.getDirectory(), toMaterialName(materialName));
    } else if (crScmMaterial instanceof CRP4Material) {
        CRP4Material crp4Material = (CRP4Material) crScmMaterial;
        P4MaterialConfig p4MaterialConfig = new P4MaterialConfig(crp4Material.getServerAndPort(), crp4Material.getView(), cipher);
        if (crp4Material.getEncryptedPassword() != null) {
            p4MaterialConfig.setEncryptedPassword(crp4Material.getEncryptedPassword());
        } else {
            p4MaterialConfig.setPassword(crp4Material.getPassword());
        }
        p4MaterialConfig.setUserName(crp4Material.getUserName());
        p4MaterialConfig.setUseTickets(crp4Material.getUseTickets());
        setCommonMaterialMembers(p4MaterialConfig, crScmMaterial);
        setCommonScmMaterialMembers(p4MaterialConfig, crp4Material);
        return p4MaterialConfig;
    } else if (crScmMaterial instanceof CRSvnMaterial) {
        CRSvnMaterial crSvnMaterial = (CRSvnMaterial) crScmMaterial;
        SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig(crSvnMaterial.getUrl(), crSvnMaterial.getUserName(), crSvnMaterial.isCheckExternals(), cipher);
        if (crSvnMaterial.getEncryptedPassword() != null) {
            svnMaterialConfig.setEncryptedPassword(crSvnMaterial.getEncryptedPassword());
        } else {
            svnMaterialConfig.setPassword(crSvnMaterial.getPassword());
        }
        setCommonMaterialMembers(svnMaterialConfig, crScmMaterial);
        setCommonScmMaterialMembers(svnMaterialConfig, crSvnMaterial);
        return svnMaterialConfig;
    } else if (crScmMaterial instanceof CRTfsMaterial) {
        CRTfsMaterial crTfsMaterial = (CRTfsMaterial) crScmMaterial;
        TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(cipher, new UrlArgument(crTfsMaterial.getUrl()), crTfsMaterial.getUserName(), crTfsMaterial.getDomain(), crTfsMaterial.getProjectPath());
        if (crTfsMaterial.getEncryptedPassword() != null) {
            tfsMaterialConfig.setEncryptedPassword(crTfsMaterial.getEncryptedPassword());
        } else {
            tfsMaterialConfig.setPassword(crTfsMaterial.getPassword());
        }
        setCommonMaterialMembers(tfsMaterialConfig, crTfsMaterial);
        setCommonScmMaterialMembers(tfsMaterialConfig, crTfsMaterial);
        return tfsMaterialConfig;
    } else
        throw new ConfigConvertionException(String.format("unknown scm material type '%s'", crScmMaterial));
}
Also used : HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)

Example 24 with HgMaterialConfig

use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.

the class PipelineConfigDependencyGraphTest method shouldReturnTheSetOfFingerprintsOfAllMaterials.

@Test
public void shouldReturnTheSetOfFingerprintsOfAllMaterials() throws Exception {
    HgMaterialConfig common = MaterialConfigsMother.hgMaterialConfig();
    SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
    GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url", "submodule", "branch", false);
    P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
    DependencyMaterialConfig up1DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first"));
    DependencyMaterialConfig up2DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first"));
    DependencyMaterialConfig uppestDependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first"));
    PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", common, up1DependencyMaterial, up2DependencyMaterial);
    PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", common, firstOrderGitMaterial, uppestDependencyMaterial);
    PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, common, uppestDependencyMaterial);
    PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", common, firstOrderP4Material);
    PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
    PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
    PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
    assertThat(dependencyGraph.allMaterialFingerprints().size(), is(7));
    assertThat(dependencyGraph.allMaterialFingerprints(), hasItems(common.getFingerprint(), firstOrderSVNMaterial.getFingerprint(), firstOrderGitMaterial.getFingerprint(), firstOrderP4Material.getFingerprint(), up1DependencyMaterial.getFingerprint(), up2DependencyMaterial.getFingerprint(), uppestDependencyMaterial.getFingerprint()));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) MaterialConfigsMother.filteredHgMaterialConfig(com.thoughtworks.go.helper.MaterialConfigsMother.filteredHgMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 25 with HgMaterialConfig

use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.

the class CruiseConfigTestBase method shouldReturnAllUniqueSchedulableScmMaterials.

@Test
public void shouldReturnAllUniqueSchedulableScmMaterials() {
    final MaterialConfig svnMaterialConfig = new SvnMaterialConfig("http://svn_url_1", "username", "password", false);
    svnMaterialConfig.setAutoUpdate(false);
    final MaterialConfig svnMaterialConfigWithAutoUpdate = new SvnMaterialConfig("http://svn_url_2", "username", "password", false);
    svnMaterialConfigWithAutoUpdate.setAutoUpdate(true);
    final MaterialConfig hgMaterialConfig = new HgMaterialConfig("http://hg_url", null);
    hgMaterialConfig.setAutoUpdate(false);
    final MaterialConfig gitMaterialConfig = new GitMaterialConfig("http://git_url");
    gitMaterialConfig.setAutoUpdate(false);
    final MaterialConfig tfsMaterialConfig = new TfsMaterialConfig(mock(GoCipher.class), new UrlArgument("http://tfs_url"), "username", "domain", "password", "project_path");
    tfsMaterialConfig.setAutoUpdate(false);
    final MaterialConfig p4MaterialConfig = new P4MaterialConfig("http://p4_url", "view", "username");
    p4MaterialConfig.setAutoUpdate(false);
    final MaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
    final PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig("scm-id-1", null, null);
    pluggableSCMMaterialConfig.getSCMConfig().setAutoUpdate(false);
    final PipelineConfig p1 = PipelineConfigMother.pipelineConfig("pipeline1", new MaterialConfigs(svnMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p2 = PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(svnMaterialConfig, gitMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p3 = PipelineConfigMother.pipelineConfig("pipeline3", new MaterialConfigs(hgMaterialConfig, dependencyMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p4 = PipelineConfigMother.pipelineConfig("pipeline4", new MaterialConfigs(p4MaterialConfig, pluggableSCMMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p5 = PipelineConfigMother.pipelineConfig("pipeline5", new MaterialConfigs(svnMaterialConfigWithAutoUpdate, tfsMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    cruiseConfig.getGroups().add(new BasicPipelineConfigs(p1, p2, p3, p4, p5));
    final Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
    assertThat(materials.size(), is(6));
    assertThat(materials, hasItems(svnMaterialConfig, hgMaterialConfig, gitMaterialConfig, tfsMaterialConfig, p4MaterialConfig, pluggableSCMMaterialConfig));
    assertThat(materials, not(hasItem(svnMaterialConfigWithAutoUpdate)));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GoCipher(com.thoughtworks.go.security.GoCipher) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.Test)

Aggregations

HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)71 Test (org.junit.Test)60 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)15 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)12 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)11 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)11 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)8 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)8 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)8 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)7 HashMap (java.util.HashMap)7 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)6 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)6 MaterialUpdateStatusListener (com.thoughtworks.go.server.materials.MaterialUpdateStatusListener)5 Filter (com.thoughtworks.go.config.materials.Filter)4 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)4 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)4