Search in sources :

Example 16 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class BuildCauseProducerServiceTest method manualTrigger_shouldUpdatePipelineConfigWhenMaterialIsConfigRepo.

@Test
public void manualTrigger_shouldUpdatePipelineConfigWhenMaterialIsConfigRepo() {
    HgMaterial material1 = new HgMaterial("url", null);
    HgMaterialConfig materialConfig1 = new HgMaterialConfig("url", null);
    pipelineConfig.addMaterialConfig(materialConfig1);
    pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig1, "plug"), "revision1"));
    when(materialConfigConverter.toMaterial(materialConfig1)).thenReturn(material1);
    when(goConfigService.hasPipelineNamed(pipelineConfig.name())).thenReturn(true);
    buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(new HashMap<>(), new HashMap<>(), new HashMap<>()), new ServerHealthStateOperationResult());
    verify(goConfigService, times(1)).pipelineConfigNamed(pipelineConfig.name());
    MaterialUpdateStatusListener statusListener = extractMaterialListenerInstanceFromRegisterCall();
    statusListener.onMaterialUpdate(new MaterialUpdateSuccessfulMessage(material1, 0));
    verify(mockMaterialUpdateStatusNotifier).removeListenerFor(pipelineConfig);
    verify(goConfigService, times(2)).pipelineConfigNamed(pipelineConfig.name());
}
Also used : MaterialUpdateStatusListener(com.thoughtworks.go.server.materials.MaterialUpdateStatusListener) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) HashMap(java.util.HashMap) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) MaterialUpdateSuccessfulMessage(com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage) Test(org.junit.Test)

Example 17 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class MergeOriginConfigTest method shouldShowDisplayName.

@Test
public void shouldShowDisplayName() {
    FileConfigOrigin fileConfigOrigin = new FileConfigOrigin();
    RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(new ConfigRepoConfig(new SvnMaterialConfig("http://mysvn", false), "myplugin"), "123");
    MergeConfigOrigin mergeOrigin = new MergeConfigOrigin(fileConfigOrigin, repoConfigOrigin);
    assertThat(mergeOrigin.displayName(), is("Merged: [ cruise-config.xml; http://mysvn at 123; ]"));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

Example 18 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class GoConfigMother method configWithConfigRepo.

public static CruiseConfig configWithConfigRepo() {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(new GitMaterialConfig("https://github.com/tomzo/gocd-indep-config-part.git"), "myplugin")));
    return cruiseConfig;
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig)

Example 19 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class GoRepoConfigDataSource method onCheckoutComplete.

public void onCheckoutComplete(MaterialConfig material, File folder, String revision) {
    // called when pipelines/flyweight/[flyweight] has a clean checkout of latest material
    // Having modifications in signature might seem like an overkill
    // but on the other hand if plugin is smart enough it could
    // parse only files that have changed, which is a huge performance gain where there are many pipelines
    /* if this is material listed in config-repos
           Then ask for config plugin implementation
           Give it the directory and store partial config
           post event about completed (successful or not) parsing
         */
    String fingerprint = material.getFingerprint();
    if (this.configWatchList.hasConfigRepoWithFingerprint(fingerprint)) {
        PartialConfigProvider plugin = null;
        ConfigRepoConfig repoConfig = configWatchList.getConfigRepoForMaterial(material);
        HealthStateScope scope = HealthStateScope.forPartialConfigRepo(repoConfig);
        try {
            plugin = this.configPluginService.partialConfigProviderFor(repoConfig);
        } catch (Exception ex) {
            fingerprintOfPartialToLatestParseResultMap.put(fingerprint, new PartialConfigParseResult(revision, ex));
            LOGGER.error(String.format("Failed to get config plugin for %s", material.getDisplayName()));
            String message = String.format("Failed to obtain configuration plugin '%s' for material: %s", repoConfig.getConfigProviderPluginName(), material.getLongDescription());
            String errorDescription = ex.getMessage() == null ? ex.toString() : ex.getMessage();
            serverHealthService.update(ServerHealthState.error(message, errorDescription, HealthStateType.general(scope)));
            notifyFailureListeners(repoConfig, ex);
            return;
        }
        try {
            //TODO put modifications and previous partial config in context
            // the context is just a helper for plugin.
            PartialConfigLoadContext context = new LoadContext(repoConfig);
            PartialConfig newPart = plugin.load(folder, context);
            if (newPart == null) {
                LOGGER.warn(String.format("Parsed configuration material %s by %s is null", material.getDisplayName(), plugin.displayName()));
                newPart = new PartialConfig();
            }
            newPart.setOrigins(new RepoConfigOrigin(repoConfig, revision));
            fingerprintOfPartialToLatestParseResultMap.put(fingerprint, new PartialConfigParseResult(revision, newPart));
            serverHealthService.removeByScope(scope);
            notifySuccessListeners(repoConfig, newPart);
        } catch (Exception ex) {
            fingerprintOfPartialToLatestParseResultMap.put(fingerprint, new PartialConfigParseResult(revision, ex));
            LOGGER.error(String.format("Failed to parse configuration material %s by %s", material.getDisplayName(), plugin.displayName()));
            String message = String.format("Parsing configuration repository using %s failed for material: %s", plugin.displayName(), material.getLongDescription());
            String errorDescription = ex.getMessage() == null ? ex.toString() : ex.getMessage();
            serverHealthService.update(ServerHealthState.error(message, errorDescription, HealthStateType.general(scope)));
            notifyFailureListeners(repoConfig, ex);
        }
    }
}
Also used : HealthStateScope(com.thoughtworks.go.serverhealth.HealthStateScope) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin)

Example 20 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class ConfigSaveDeadlockDetectionIntegrationTest method configRepoDeleteThread.

private Thread configRepoDeleteThread(final ConfigRepoConfig configRepoToBeDeleted, final int counter) throws InterruptedException {
    return createThread(new Runnable() {

        @Override
        public void run() {
            goConfigService.updateConfig(new UpdateConfigCommand() {

                @Override
                public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
                    ConfigRepoConfig repoConfig = ListUtil.find(cruiseConfig.getConfigRepos(), new ListUtil.Condition() {

                        @Override
                        public <T> boolean isMet(T item) {
                            ConfigRepoConfig configRepoConfig = (ConfigRepoConfig) item;
                            return configRepoToBeDeleted.getMaterialConfig().equals(configRepoConfig.getMaterialConfig());
                        }
                    });
                    cruiseConfig.getConfigRepos().remove(repoConfig);
                    return cruiseConfig;
                }
            });
        }
    }, "config-repo-delete-thread" + counter);
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) ListUtil(com.thoughtworks.go.util.ListUtil)

Aggregations

ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)54 Test (org.junit.Test)34 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)32 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)27 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)10 ConfigReposConfig (com.thoughtworks.go.config.remote.ConfigReposConfig)8 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)8 Before (org.junit.Before)8 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)6 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)6 File (java.io.File)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 AbstractMaterialConfig (com.thoughtworks.go.config.materials.AbstractMaterialConfig)4 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)4 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)4 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)4 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)4 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)3