Search in sources :

Example 6 with P4MaterialConfig

use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.

the class P4TestRepo method materialConfig.

public P4MaterialConfig materialConfig(String p4view) {
    P4MaterialConfig p4MaterialConfig = new P4MaterialConfig(serverAndPort(), p4view);
    p4MaterialConfig.setConfigAttributes(Collections.singletonMap(P4MaterialConfig.USERNAME, user));
    p4MaterialConfig.setPassword(password);
    p4MaterialConfig.setUseTickets(useTickets);
    return p4MaterialConfig;
}
Also used : P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)

Example 7 with P4MaterialConfig

use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.

the class MaterialConfigsMother method p4MaterialConfig.

public static P4MaterialConfig p4MaterialConfig(String serverAndPort, String userName, String password, String view, boolean useTickets) {
    final P4MaterialConfig material = new P4MaterialConfig(serverAndPort, view);
    material.setConfigAttributes(m(P4MaterialConfig.USERNAME, userName, P4MaterialConfig.AUTO_UPDATE, "true"));
    material.setPassword(password);
    material.setUseTickets(useTickets);
    return material;
}
Also used : P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)

Example 8 with P4MaterialConfig

use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig 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 9 with P4MaterialConfig

use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig 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 10 with P4MaterialConfig

use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.

the class CruiseConfigTestBase method shouldCollectAllTheErrorsInTheChilderHelper.

protected void shouldCollectAllTheErrorsInTheChilderHelper(CruiseConfig config) {
    config.server().security().ldapConfig().errors().add("uri", "invalid ldap uri");
    config.server().security().ldapConfig().errors().add("searchBase", "invalid search base");
    PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString("pipeline-1"));
    pipelineConfig.errors().add("base", "Some base errors");
    P4MaterialConfig p4MaterialConfig = new P4MaterialConfig("localhost:1999", "view");
    p4MaterialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "p4_folder"));
    pipelineConfig.addMaterialConfig(p4MaterialConfig);
    p4MaterialConfig.errors().add("materialName", "material name does not follow pattern");
    StageConfig stage = pipelineConfig.first();
    stage.errors().add("role", "Roles must be proper");
    List<ConfigErrors> allErrors = config.validateAfterPreprocess();
    assertThat(allErrors.size(), is(5));
    assertThat(allErrors.get(0).on("uri"), is("invalid ldap uri"));
    assertThat(allErrors.get(0).on("searchBase"), is("invalid search base"));
    assertThat(allErrors.get(1).on("base"), is("Some base errors"));
    assertThat(allErrors.get(2).on("role"), is("Roles must be proper"));
    assertThat(allErrors.get(3).on(ScmMaterialConfig.FOLDER), is("Destination directory is required when specifying multiple scm materials"));
    assertThat(allErrors.get(4).on("materialName"), is("material name does not follow pattern"));
}
Also used : P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)

Aggregations

P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)29 Test (org.junit.Test)22 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)13 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)8 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)8 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)7 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)4 GoCipher (com.thoughtworks.go.security.GoCipher)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)3 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)3 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)2 MaterialConfigsMother.filteredHgMaterialConfig (com.thoughtworks.go.helper.MaterialConfigsMother.filteredHgMaterialConfig)2 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)2 Date (java.util.Date)2 Filter (com.thoughtworks.go.config.materials.Filter)1