Search in sources :

Example 51 with MaterialConfig

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

the class PipelineConfigDependencyGraph method unsharedMaterialConfigs.

public MaterialConfigs unsharedMaterialConfigs() {
    MaterialConfigs firstOrderMaterials = new MaterialConfigs();
    List<PipelineConfigQueueEntry> queue = new ArrayList<>(buildQueue());
    for (MaterialConfig materialConfig : current.materialConfigs()) {
        if (!existsOnAnyOfPipelinesIn(queue, materialConfig)) {
            firstOrderMaterials.add(materialConfig);
        }
    }
    return firstOrderMaterials;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) ArrayList(java.util.ArrayList) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig)

Example 52 with MaterialConfig

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

the class PipelineConfigDependencyGraph method isRevisionsOfSharedMaterialsIgnored.

public boolean isRevisionsOfSharedMaterialsIgnored(MaterialRevisions revisions) {
    MaterialConfigs unsharedScmMaterialConfigs = unsharedMaterialConfigs();
    List<PipelineConfigQueueEntry> queue = new ArrayList<>(buildQueue());
    for (MaterialRevision revision : revisions) {
        Material material = revision.getMaterial();
        MaterialConfig materialConfig = material.config();
        if (unsharedScmMaterialConfigs.hasMaterialWithFingerprint(materialConfig) || revision.isDependencyMaterialRevision()) {
            continue;
        }
        if (isThisMaterialIgnored(queue, revision, materialConfig)) {
            return true;
        }
    }
    return false;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) ArrayList(java.util.ArrayList) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Material(com.thoughtworks.go.domain.materials.Material) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 53 with MaterialConfig

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

the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldSchedulePipelineWithSameMaterialIn2DestinationsWhenManuallyTriggered_WithSpecifiedRevisions.

@Test
public void shouldSchedulePipelineWithSameMaterialIn2DestinationsWhenManuallyTriggered_WithSpecifiedRevisions() throws Exception {
    pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
    pipelineConfig.materialConfigs().clear();
    materialConfig = hgRepo.createMaterialConfig("dest1");
    materialConfig.setAutoUpdate(true);
    // new material is added
    MaterialConfig otherMaterialConfig = hgRepo.createMaterialConfig("dest2");
    otherMaterialConfig.setAutoUpdate(true);
    pipelineConfig.materialConfigs().add(materialConfig);
    pipelineConfig.materialConfigs().add(otherMaterialConfig);
    List<Modification> firstBuildModifications = configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
    materialUpdateService.updateMaterial(material);
    waitForMaterialNotInProgress();
    cachedGoConfig.throwExceptionIfExists();
    final HashMap<String, String> revisions = new HashMap<>();
    final HashMap<String, String> environmentVariables = new HashMap<>();
    buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
    cachedGoConfig.throwExceptionIfExists();
    Map<CaseInsensitiveString, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(5);
    assertThat(afterLoad.keySet(), hasItem(new CaseInsensitiveString(PIPELINE_NAME)));
    BuildCause cause = afterLoad.get(new CaseInsensitiveString(PIPELINE_NAME));
    assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
    List<Modification> secondBuildModifications = configTestRepo.addCodeToRepositoryAndPush("a.java", "added code file", "some java code");
    materialUpdateService.updateMaterial(material);
    waitForMaterialNotInProgress();
    pipelineScheduleQueue.clear();
    // revision in dest 1 will be older by 1 commit - this is kind of scm-config-consistency violation
    String explicitRevision = firstBuildModifications.get(0).getRevision();
    revisions.put(materialConfig.getPipelineUniqueFingerprint(), explicitRevision);
    buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, new Username(new CaseInsensitiveString("Admin")), new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
    cachedGoConfig.throwExceptionIfExists();
    afterLoad = scheduleHelper.waitForAnyScheduled(5);
    assertThat(afterLoad.keySet(), hasItem(new CaseInsensitiveString(PIPELINE_NAME)));
    cause = afterLoad.get(new CaseInsensitiveString(PIPELINE_NAME));
    assertThat(cause.getBuildCauseMessage(), containsString("Forced by Admin"));
    PipelineConfig pipelineConfigAfterSchedule = goConfigService.pipelineConfigNamed(pipelineConfig.name());
    RepoConfigOrigin configOriginAfterSchedule = (RepoConfigOrigin) pipelineConfigAfterSchedule.getOrigin();
    String lastPushedRevision = secondBuildModifications.get(0).getRevision();
    assertThat("revisionOfPipelineConfigOriginShouldMatchLastPushedCommit", configOriginAfterSchedule.getRevision(), is(lastPushedRevision));
    assertThat(pipelineConfigAfterSchedule.materialConfigs(), hasItem(otherMaterialConfig));
    assertThat("buildCauseRevisionShouldMatchSpecifiedRevision", cause.getMaterialRevisions().latestRevision(), is(explicitRevision));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) HashMap(java.util.HashMap) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) Username(com.thoughtworks.go.server.domain.Username) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.jupiter.api.Test)

Example 54 with MaterialConfig

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

the class ConfigRepoServiceIntegrationTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    user = new Username(new CaseInsensitiveString("current"));
    UpdateConfigCommand command = goConfigService.modifyAdminPrivilegesCommand(asList(user.getUsername().toString()), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.add));
    goConfigService.updateConfig(command);
    this.repoId = "repo-1";
    this.pluginId = "json-config-repo-plugin";
    MaterialConfig repoMaterial = git("https://foo.git", "master");
    this.configRepo = ConfigRepoConfig.createConfigRepoConfig(repoMaterial, pluginId, repoId);
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    goConfigService.forceNotifyListeners();
}
Also used : UpdateConfigCommand(com.thoughtworks.go.config.UpdateConfigCommand) Username(com.thoughtworks.go.server.domain.Username) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) TriStateSelection(com.thoughtworks.go.presentation.TriStateSelection) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 55 with MaterialConfig

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

the class BuildCause method assertPipelineConfigAndMaterialRevisionMatch.

public void assertPipelineConfigAndMaterialRevisionMatch(PipelineConfig pipelineConfig) {
    if (!pipelineConfig.isConfigOriginSameAsOneOfMaterials()) {
        return;
    }
    // then config and code revision must both match
    if (this.trigger.isForced() || this.hasDependencyMaterials()) {
        // and possibility to specify revisions to run with
        return;
    }
    RepoConfigOrigin repoConfigOrigin = (RepoConfigOrigin) pipelineConfig.getOrigin();
    MaterialConfig configAndCodeMaterial = repoConfigOrigin.getMaterial();
    // TODO if revision in any of the pipelines match
    MaterialRevision revision = this.getMaterialRevisions().findRevisionForFingerPrint(configAndCodeMaterial.getFingerprint());
    String revisionString = revision.getRevision().getRevision();
    if (pipelineConfig.isConfigOriginFromRevision(revisionString)) {
        return;
    }
    invalidRevision(repoConfigOrigin.getRevision(), revisionString);
}
Also used : MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

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