Search in sources :

Example 76 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ConfigRepositoryInitializer method initializeConfigRepository.

private void initializeConfigRepository(ConfigRepoConfig repo) {
    MaterialConfig materialConfig = repo.getRepo();
    Material material = new Materials(new MaterialConfigs(materialConfig)).first();
    MaterialInstance materialInstance = this.materialRepository.findMaterialInstance(materialConfig);
    if (materialInstance != null) {
        File folder = materialRepository.folderFor(material);
        MaterialRevisions latestModification = materialRepository.findLatestModification(material);
        Modification modification = latestModification.firstModifiedMaterialRevision().getLatestModification();
        try {
            LOGGER.debug("[Config Repository Initializer] Initializing config repository '{}'. Loading the GoCD configuration from last fetched modification '{}'.", repo.getId(), modification.getRevision());
            goConfigRepoConfigDataSource.onCheckoutComplete(materialConfig, folder, modification);
        } catch (Exception e) {
            LOGGER.error(String.format("[Config Repository Initializer] an error occurred while initializing '%s' config repository.", repo.getId()), e);
        // Do nothing when error occurs while initializing the config repository.
        // The config repo initialization may fail due to config repo errors (config errors, or rules violation errors)
        }
    } else {
        LOGGER.debug("[Config Repository Initializer] Skipped initializing config repository '{}'. Could not find material repository under flyweight folder.", repo.getId());
    }
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Material(com.thoughtworks.go.domain.materials.Material) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) File(java.io.File)

Example 77 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class PipelineRepositoryIntegrationTest method shouldConsider_firstRevision_forAFlyweight_asInDb_whilePickingFromMultipleDeclarations.

@Test
public void shouldConsider_firstRevision_forAFlyweight_asInDb_whilePickingFromMultipleDeclarations() {
    ScheduleTestUtil u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
    int i = 1;
    GitMaterial git1 = u.wf(new GitMaterial("git"), "folder1");
    u.checkinInOrder(git1, "g1");
    GitMaterial git2 = u.wf(new GitMaterial("git"), "folder2");
    ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("P", u.m(git1), u.m(git2));
    CruiseConfig cruiseConfig = goConfigDao.load();
    u.checkinInOrder(git1, u.d(i++), "g2");
    u.runAndPass(p, "g1", "g2");
    u.runAndPass(p, "g2", "g1");
    PipelineTimeline timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    timeline.updateTimelineOnInit();
    List<PipelineTimelineEntry> timelineEntries = new ArrayList<>(timeline.getEntriesFor("P"));
    assertThat(timelineEntries.get(0).getPipelineLocator().getCounter(), is(1));
    assertThat(timelineEntries.get(0).naturalOrder(), is(1.0));
    List<PipelineTimelineEntry.Revision> flyweightsRevs = new ArrayList<>(timelineEntries.get(0).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g1"));
    assertThat(flyweightsRevs.get(1).revision, is("g2"));
    assertThat(timelineEntries.get(1).getPipelineLocator().getCounter(), is(2));
    assertThat(timelineEntries.get(1).naturalOrder(), is(2.0));
    flyweightsRevs = new ArrayList<>(timelineEntries.get(1).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g2"));
    assertThat(flyweightsRevs.get(1).revision, is("g1"));
    MaterialConfigs materials = configHelper.deepClone(p.config.materialConfigs());
    Collections.reverse(materials);
    configHelper.setMaterialConfigForPipeline("P", materials.toArray(new MaterialConfig[0]));
    goConfigDao.load();
    timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    timeline.updateTimelineOnInit();
    timelineEntries = new ArrayList<>(timeline.getEntriesFor("P"));
    assertThat(timelineEntries.get(0).getPipelineLocator().getCounter(), is(1));
    assertThat(timelineEntries.get(0).naturalOrder(), is(1.0));
    flyweightsRevs = new ArrayList<>(timelineEntries.get(0).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g1"));
    assertThat(flyweightsRevs.get(1).revision, is("g2"));
    assertThat(timelineEntries.get(1).getPipelineLocator().getCounter(), is(2));
    assertThat(timelineEntries.get(1).naturalOrder(), is(2.0));
    flyweightsRevs = new ArrayList<>(timelineEntries.get(1).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g2"));
    assertThat(flyweightsRevs.get(1).revision, is("g1"));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) Test(org.junit.jupiter.api.Test)

Example 78 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class PipelineScheduleQueueIntegrationTest method shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision.

@Test
public void shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision() {
    PipelineConfig pipelineConfig = fixture.pipelineConfig();
    BuildCause cause = modifySomeFilesAndTriggerAs(pipelineConfig, "cruise-developer");
    MaterialConfig materialConfig = pipelineConfig.materialConfigs().first();
    cause.getMaterialRevisions().findRevisionFor(materialConfig);
    pipelineConfig.setOrigins(new RepoConfigOrigin(ConfigRepoConfig.createConfigRepoConfig(materialConfig, "123", "id1"), "plug"));
    saveRev(cause);
    queue.schedule(new CaseInsensitiveString(fixture.pipelineName), cause);
    Pipeline pipeline = queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider());
    assertThat(pipeline, is(nullValue()));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.jupiter.api.Test)

Example 79 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class CruiseConfigTestBase method getAllUniquePostCommitSchedulableMaterials_shouldReturnMaterialsWithAutoUpdateFalseAndConfigRepos.

@Test
public void getAllUniquePostCommitSchedulableMaterials_shouldReturnMaterialsWithAutoUpdateFalseAndConfigRepos() {
    GitMaterialConfig gitAutoMaterial = MaterialConfigsMother.gitMaterialConfig("url");
    PipelineConfig pipelineAuto = pipelineConfig("pipelineAuto", new MaterialConfigs(gitAutoMaterial));
    GitMaterialConfig gitNonAutoMaterial = new GitMaterialConfig(new UrlArgument("other-url"), "master", "dest", false, null, false, null, new CaseInsensitiveString("git"), false);
    PipelineConfig pipelineTriggerable = pipelineConfig("pipelineTriggerable", new MaterialConfigs(gitNonAutoMaterial));
    PipelineConfigs defaultGroup = createGroup("defaultGroup", pipelineAuto, pipelineTriggerable);
    cruiseConfig = new BasicCruiseConfig(defaultGroup);
    ConfigReposConfig reposConfig = new ConfigReposConfig();
    GitMaterialConfig configRepoMaterial = new GitMaterialConfig("http://git");
    reposConfig.add(new ConfigRepoConfig(configRepoMaterial, "myplug"));
    cruiseConfig.setConfigRepos(reposConfig);
    PipelineGroups pipelineGroups = new PipelineGroups(defaultGroup);
    Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
    assertThat(materials.size(), is(2));
    assertThat(materials, hasItem(gitNonAutoMaterial));
    assertThat(materials, hasItem(configRepoMaterial));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) 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) MergePipelineConfigs(com.thoughtworks.go.config.merge.MergePipelineConfigs) Test(org.junit.Test)

Example 80 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldReturnMaterialBasedOnPiplineUniqueFingerPrint.

@Test
public void shouldReturnMaterialBasedOnPiplineUniqueFingerPrint() {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
    HgMaterialConfig expectedMaterial = MaterialConfigsMother.hgMaterialConfig();
    pipeline1.addMaterialConfig(expectedMaterial);
    pipeline1.addMaterialConfig(MaterialConfigsMother.gitMaterialConfig("url"));
    pipeline1.addMaterialConfig(MaterialConfigsMother.svnMaterialConfig("url", "folder"));
    MaterialConfig actualMaterialConfig = pipeline1.materialConfigs().getByFingerPrint(expectedMaterial.getPipelineUniqueFingerprint());
    assertThat(actualMaterialConfig, is(expectedMaterial));
}
Also used : HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) 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) Test(org.junit.Test)

Aggregations

MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)171 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)90 Test (org.junit.jupiter.api.Test)86 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)74 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)64 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)48 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)44 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)42 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)42 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)39 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)36 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)20 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)19 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)19 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)13 Material (com.thoughtworks.go.domain.materials.Material)13 Modification (com.thoughtworks.go.domain.materials.Modification)13 Test (org.junit.Test)12