Search in sources :

Example 11 with P4Material

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

the class P4MaterialInstance method toOldMaterial.

@Override
public Material toOldMaterial(String name, String folder, String password) {
    P4Material p4 = new P4Material(url, view, username, folder);
    setName(name, p4);
    p4.setFolder(StringUtils.isBlank(folder) ? null : folder);
    p4.setPassword(password);
    p4.setUseTickets(getUseTickets());
    p4.setId(id);
    return p4;
}
Also used : P4Material(com.thoughtworks.go.config.materials.perforce.P4Material)

Example 12 with P4Material

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

the class MaterialRevisions method updateToCommand.

public BuildCommand updateToCommand(String baseDir) {
    List<BuildCommand> commands = new ArrayList<>();
    for (MaterialRevision revision : revisions) {
        Material material = revision.getMaterial();
        if (material instanceof ScmMaterial) {
            if (material instanceof GitMaterial) {
                GitMaterialUpdater updater = new GitMaterialUpdater((GitMaterial) material);
                commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
            } else if (material instanceof HgMaterial) {
                HgMaterialUpdater updater = new HgMaterialUpdater((HgMaterial) material);
                commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
            } else if (material instanceof SvnMaterial) {
                SvnMaterialUpdater updater = new SvnMaterialUpdater((SvnMaterial) material);
                commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
            } else if (material instanceof PackageMaterial) {
            // do nothing
            } else if (material instanceof TfsMaterial) {
                TfsMaterialUpdater updater = new TfsMaterialUpdater((TfsMaterial) material);
                commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
            } else if (material instanceof P4Material) {
                P4MaterialUpdater updater = new P4MaterialUpdater((P4Material) material);
                commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
            } else {
                commands.add(BuildCommand.fail("%s Material is not supported for new build command agent", material.getTypeForDisplay()));
            }
        }
    }
    return BuildCommand.compose(commands);
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) P4MaterialUpdater(com.thoughtworks.go.domain.materials.perforce.P4MaterialUpdater) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) GitMaterialUpdater(com.thoughtworks.go.domain.materials.git.GitMaterialUpdater) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) SvnMaterialUpdater(com.thoughtworks.go.domain.materials.svn.SvnMaterialUpdater) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) HgMaterialUpdater(com.thoughtworks.go.domain.materials.mercurial.HgMaterialUpdater) TfsMaterialUpdater(com.thoughtworks.go.domain.materials.tfs.TfsMaterialUpdater) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)

Example 13 with P4Material

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

the class StageServiceIntegrationTest method setup2DependentInstances.

private PipelineConfig setup2DependentInstances(MingleConfig upstreamMingle, MingleConfig downstreamMingle) {
    Username loser = new Username(new CaseInsensitiveString("loser"));
    ManualBuild build = new ManualBuild(loser);
    Date checkinTime = new Date();
    GitMaterial git = MaterialsMother.gitMaterial("http://google.com", null, "master");
    git.setFolder("git");
    HgMaterial hg = MaterialsMother.hgMaterial();
    hg.setFolder("hg");
    PipelineConfig upstreamWithMingle = PipelineConfigMother.createPipelineConfig("upstream-with-mingle", "stage", "build");
    upstreamWithMingle.setMaterialConfigs(new MaterialConfigs(git.config(), hg.config()));
    upstreamWithMingle.setMingleConfig(upstreamMingle);
    configFileHelper.addPipelineToGroup(upstreamWithMingle, "upstream-with-mingle");
    P4Material p4 = MaterialsMother.p4Material("loser:007", "loser", "boozer", "through-the-window", true);
    PipelineConfig upstreamWithoutMingle = PipelineConfigMother.createPipelineConfig("upstream-without-mingle", "stage", "build");
    upstreamWithoutMingle.setMaterialConfigs(new MaterialConfigs(p4.config()));
    configFileHelper.addPipelineToGroup(upstreamWithoutMingle, "upstream-without-mingle");
    DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial(upstreamWithMingle.name().toString(), upstreamWithMingle.get(0).name().toString());
    SvnMaterial svn = MaterialsMother.svnMaterial("http://svn.com");
    DependencyMaterial dependencyMaterialViaP4 = MaterialsMother.dependencyMaterial(upstreamWithoutMingle.name().toString(), upstreamWithoutMingle.get(0).name().toString());
    PipelineConfig downstream = PipelineConfigMother.createPipelineConfig("downstream", "down-stage", "job");
    downstream.setMaterialConfigs(new MaterialConfigs(dependencyMaterial.config(), svn.config(), dependencyMaterialViaP4.config()));
    downstream.setMingleConfig(downstreamMingle);
    configFileHelper.addPipelineToGroup(downstream, "downstream");
    // mingle card nos.
    // svn: 1xx
    // p4: 2xx
    // hg: 3xx
    // git: 4xx
    Modification svnCommit1 = checkin(svn, "888", "svn commit #101 1", "svn 1 guy", "svn.1@gmail.com", checkinTime);
    Modification hgCommit1 = checkin(hg, "abcd", "hg commit 1 #301", "hg 1 guy", "hg.1@gmail.com", checkinTime);
    Modification gitCommit1 = checkin(git, "1234", "#401 - git commit 1", "git 1 guy", "git.1@gmail.com", checkinTime);
    // used in a later instance
    Modification gitCommit2 = checkin(git, "2355", "git #402 commit 2", "git 2&3 guy", "git.2.and.3@gmail.com", checkinTime);
    Modification hgCommit2 = checkin(hg, "abc", "hg commit #302 2", "hg 2 guy", null, checkinTime);
    Pipeline pipelineOne = dbHelper.checkinRevisionsToBuild(build, upstreamWithMingle, new MaterialRevision(git, gitCommit1), new MaterialRevision(hg, hgCommit2, hgCommit1));
    Modification hgCommit3 = checkin(hg, "bcde", "hg commit 3 #303", "hg 3 guy", "hg.3@gmail.com", checkinTime);
    Modification gitCommit3 = checkin(git, "567", "git #403 commit 3", "git 2&3 guy", "git.2.and.3@gmail.com", checkinTime);
    Pipeline pipelineTwo = dbHelper.checkinRevisionsToBuild(build, upstreamWithMingle, new MaterialRevision(git, gitCommit3, gitCommit2), new MaterialRevision(hg, hgCommit3));
    Modification p4Commit1 = checkin(p4, "777", "#201 - p4 commit 1", "p4 1 guy", "p4.1@gmail.com", checkinTime);
    Pipeline pipelineP4 = dbHelper.checkinRevisionsToBuild(build, upstreamWithoutMingle, new MaterialRevision(p4, p4Commit1));
    ArrayList<MaterialRevision> materialRevisionsFor1 = new ArrayList<>();
    dbHelper.addDependencyRevisionModification(materialRevisionsFor1, dependencyMaterial, pipelineOne);
    dbHelper.addDependencyRevisionModification(materialRevisionsFor1, dependencyMaterialViaP4, pipelineP4);
    Modification svnCommit2 = checkin(svn, "999", "svn #102 commit 2", "svn 2 guy", "svn.2@gmail.com", checkinTime);
    materialRevisionsFor1.add(new MaterialRevision(svn, svnCommit2, svnCommit1));
    // save downstream pipeline 1
    dbHelper.passPipeline(dbHelper.checkinRevisionsToBuild(build, downstream, materialRevisionsFor1));
    Modification p4Commit2 = checkin(p4, "007", "#202 - p4 commit 2", "p4 2 guy", "p4.2@gmail.com", checkinTime);
    Pipeline pipeline2P4 = dbHelper.checkinRevisionsToBuild(build, upstreamWithoutMingle, new MaterialRevision(p4, p4Commit2));
    ArrayList<MaterialRevision> materialRevisionsFor2 = new ArrayList<>();
    dbHelper.addDependencyRevisionModification(materialRevisionsFor2, dependencyMaterial, pipelineTwo);
    dbHelper.addDependencyRevisionModification(materialRevisionsFor2, dependencyMaterialViaP4, pipeline2P4);
    Modification svnCommit3 = checkin(svn, "1000", "svn commit #103 3", "svn 3 guy", "svn.3@gmail.com", checkinTime);
    materialRevisionsFor2.add(new MaterialRevision(svn, svnCommit3));
    // save downstream pipeline 2
    dbHelper.passPipeline(dbHelper.checkinRevisionsToBuild(build, downstream, materialRevisionsFor2));
    return downstream;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) Modification(com.thoughtworks.go.domain.materials.Modification) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) ArrayList(java.util.ArrayList) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) Date(java.util.Date) Username(com.thoughtworks.go.server.domain.Username) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial)

Example 14 with P4Material

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

the class PipelineMother method pipelineWithAllTypesOfMaterials.

public static Pipeline pipelineWithAllTypesOfMaterials(String pipelineName, String stageName, String jobName, String fixedMaterialRevisionForAllMaterials) {
    GitMaterial gitMaterial = MaterialsMother.gitMaterial("http://user:password@gitrepo.com", null, "branch");
    HgMaterial hgMaterial = MaterialsMother.hgMaterial("http://user:password@hgrepo.com");
    SvnMaterial svnMaterial = MaterialsMother.svnMaterial("http://user:password@svnrepo.com", null, "username", "password", false, null);
    TfsMaterial tfsMaterial = MaterialsMother.tfsMaterial("http://user:password@tfsrepo.com");
    P4Material p4Material = MaterialsMother.p4Material("127.0.0.1:1666", "username", "password", "view", false);
    DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial();
    PackageMaterial packageMaterial = MaterialsMother.packageMaterial();
    PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial();
    Materials materials = new Materials(gitMaterial, hgMaterial, svnMaterial, tfsMaterial, p4Material, dependencyMaterial, packageMaterial, pluggableSCMMaterial);
    return new Pipeline(pipelineName, BuildCause.createWithModifications(ModificationsMother.modifyOneFile(materials, fixedMaterialRevisionForAllMaterials), ""), StageMother.passedStageInstance(stageName, jobName, pipelineName));
}
Also used : TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material)

Example 15 with P4Material

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

the class PipelineSqlMapDaoIntegrationTest method shouldPersistMaterialsWithRealPassword.

@Test
public void shouldPersistMaterialsWithRealPassword() {
    MaterialRevisions materialRevisions = new MaterialRevisions();
    addRevision(materialRevisions, MaterialsMother.svnMaterial("http://username:password@localhost"));
    addRevision(materialRevisions, MaterialsMother.hgMaterial("http://username:password@localhost"));
    addRevision(materialRevisions, new GitMaterial("git://username:password@localhost"));
    addRevision(materialRevisions, new P4Material("localhost:1666", "view"));
    BuildCause buildCause = BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS);
    Pipeline pipeline = new Pipeline("Test", buildCause);
    save(pipeline);
    Pipeline loaded = pipelineDao.mostRecentPipeline("Test");
    Materials materials = loaded.getMaterials();
    for (Material material : materials) {
        assertThat(((ScmMaterial) material).getUrl(), not(containsString("******")));
    }
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Materials(com.thoughtworks.go.config.materials.Materials) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Material(com.thoughtworks.go.domain.materials.Material) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.jupiter.api.Test)

Aggregations

P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)18 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)9 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)8 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)8 Test (org.junit.jupiter.api.Test)8 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)7 TfsMaterial (com.thoughtworks.go.config.materials.tfs.TfsMaterial)5 Materials (com.thoughtworks.go.config.materials.Materials)3 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)3 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)3 Modification (com.thoughtworks.go.domain.materials.Modification)3 ArrayList (java.util.ArrayList)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)2 Material (com.thoughtworks.go.domain.materials.Material)2 HgMaterialInstance (com.thoughtworks.go.domain.materials.mercurial.HgMaterialInstance)2 PackageMaterialInstance (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialInstance)2 P4MaterialInstance (com.thoughtworks.go.domain.materials.perforce.P4MaterialInstance)2 PluggableSCMMaterialInstance (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance)2 SvnMaterialInstance (com.thoughtworks.go.domain.materials.svn.SvnMaterialInstance)2