Search in sources :

Example 61 with SvnMaterialConfig

use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.

the class GoConfigMaterialsTest method pipelineWithManyMaterials.

private PipelineConfig pipelineWithManyMaterials(boolean autoUpdate) {
    SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
    svnMaterialConfig.setAutoUpdate(autoUpdate);
    MaterialConfig gitMaterialConfig = MaterialConfigsMother.gitMaterialConfig("/foo/bar.git");
    HgMaterialConfig hgMaterialConfig = MaterialConfigsMother.hgMaterialConfig();
    P4MaterialConfig p4MaterialConfig = MaterialConfigsMother.p4MaterialConfig();
    return new PipelineConfig(new CaseInsensitiveString("pipeline1"), new MaterialConfigs(svnMaterialConfig, hgMaterialConfig, gitMaterialConfig, p4MaterialConfig));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)

Example 62 with SvnMaterialConfig

use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.

the class GoConfigMaterialsTest method shouldProvideSetOfSchedulableMaterials.

@Test
public void shouldProvideSetOfSchedulableMaterials() {
    SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig("url", "svnDir", true);
    PipelineConfig pipeline1 = new PipelineConfig(new CaseInsensitiveString("pipeline1"), new MaterialConfigs(svnMaterialConfig));
    CruiseConfig config = new BasicCruiseConfig(new BasicPipelineConfigs(pipeline1));
    assertThat(config.getAllUniqueMaterialsBelongingToAutoPipelines(), hasItem(svnMaterialConfig));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

Example 63 with SvnMaterialConfig

use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldMigrateEncryptedMaterialPasswordWithNewlineAndSpaces_XslMigrationFrom88To90.

@Test
public void shouldMigrateEncryptedMaterialPasswordWithNewlineAndSpaces_XslMigrationFrom88To90() throws Exception {
    String plainText = "something";
    String encryptedValue = new GoCipher().encrypt(plainText);
    String encryptedValueWithWhitespaceAndNewline = new StringBuilder(encryptedValue).insert(2, "\r\n" + "                        ").toString();
    String content = configWithPipeline("<pipeline name='some_pipeline'>" + "    <materials>" + "      <svn url='asdsa' username='user' encryptedPassword='" + encryptedValueWithWhitespaceAndNewline + "' dest='svn'>" + "<filter>\n" + "            <ignore pattern='**/*' />\n" + "          </filter>" + "</svn>" + "<tfs url='tfsurl' username='user' domain='domain' encryptedPassword='" + encryptedValueWithWhitespaceAndNewline + "' projectPath='path' dest='tfs' />" + "<p4 port='host:9999' username='user' encryptedPassword='" + encryptedValueWithWhitespaceAndNewline + "' dest='perforce'>\n" + "          <view><![CDATA[view]]></view>\n" + "        </p4>" + "    </materials>" + "  <stage name='some_stage'>" + "    <jobs>" + "      <job name='some_job'>" + "      </job>" + "    </jobs>" + "  </stage>" + "</pipeline>", 88);
    CruiseConfig config = ConfigMigrator.loadWithMigration(content).config;
    MaterialConfigs materialConfigs = config.allPipelines().get(0).materialConfigs();
    SvnMaterialConfig svnMaterialConfig = (SvnMaterialConfig) materialConfigs.get(0);
    assertThat(svnMaterialConfig.getPassword(), is(plainText));
    assertThat(svnMaterialConfig.getEncryptedPassword(), is(encryptedValue));
    assertThat(svnMaterialConfig.getFilterAsString(), is("**/*"));
    TfsMaterialConfig tfs = (TfsMaterialConfig) materialConfigs.get(1);
    assertThat(tfs.getPassword(), is(plainText));
    assertThat(tfs.getEncryptedPassword(), is(encryptedValue));
    assertThat(tfs.getUrl(), is("tfsurl"));
    P4MaterialConfig p4 = (P4MaterialConfig) materialConfigs.get(2);
    assertThat(p4.getPassword(), is(plainText));
    assertThat(p4.getEncryptedPassword(), is(encryptedValue));
    assertThat(p4.getServerAndPort(), is("host:9999"));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

Example 64 with SvnMaterialConfig

use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldBeSvnMaterial.

private void shouldBeSvnMaterial(MaterialConfig material) {
    assertThat(material, is(instanceOf(SvnMaterialConfig.class)));
    SvnMaterialConfig svnMaterial = (SvnMaterialConfig) material;
    assertThat(svnMaterial.getUrl(), is("svnUrl"));
    assertThat(svnMaterial.isCheckExternals(), is(true));
}
Also used : SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)

Example 65 with SvnMaterialConfig

use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.

the class ScheduledPipelineLoaderIntegrationTest method shouldSetAServerHealthMessageWhenMaterialForPipelineWithBuildCauseIsNotFound.

@Test
public void shouldSetAServerHealthMessageWhenMaterialForPipelineWithBuildCauseIsNotFound() throws IllegalArtifactLocationException, IOException {
    PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("last", new StageConfig(new CaseInsensitiveString("stage"), new JobConfigs(new JobConfig("job-one"))));
    pipelineConfig.materialConfigs().clear();
    SvnMaterialConfig onDirOne = MaterialConfigsMother.svnMaterialConfig("google.com", "dirOne", "loser", "boozer", false, "**/*.html");
    final P4MaterialConfig onDirTwo = MaterialConfigsMother.p4MaterialConfig("host:987654321", "zoozer", "secret", "through-the-window", true);
    onDirTwo.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "dirTwo"));
    pipelineConfig.addMaterialConfig(onDirOne);
    pipelineConfig.addMaterialConfig(onDirTwo);
    configHelper.addPipeline(pipelineConfig);
    Pipeline building = PipelineMother.building(pipelineConfig);
    final Pipeline pipeline = dbHelper.savePipelineWithMaterials(building);
    CruiseConfig cruiseConfig = configHelper.currentConfig();
    PipelineConfig cfg = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("last"));
    cfg.removeMaterialConfig(cfg.materialConfigs().get(1));
    configHelper.writeConfigFile(cruiseConfig);
    assertThat(serverHealthService.filterByScope(HealthStateScope.forPipeline("last")).size(), is(0));
    final long jobId = pipeline.getStages().get(0).getJobInstances().get(0).getId();
    Date currentTime = new Date(System.currentTimeMillis() - 1);
    Pipeline loadedPipeline = (Pipeline) transactionTemplate.execute(new TransactionCallback() {

        public Object doInTransaction(TransactionStatus status) {
            Pipeline loadedPipeline = null;
            try {
                loadedPipeline = loader.pipelineWithPasswordAwareBuildCauseByBuildId(jobId);
                fail("should not have loaded pipeline with build-cause as one of the necessary materials was not found");
            } catch (Exception e) {
                assertThat(e, is(instanceOf(StaleMaterialsOnBuildCause.class)));
                assertThat(e.getMessage(), is("Cannot load job 'last/" + pipeline.getCounter() + "/stage/1/job-one' because material " + onDirTwo + " was not found in config."));
            }
            return loadedPipeline;
        }
    });
    assertThat(loadedPipeline, is(nullValue()));
    JobInstance reloadedJobInstance = jobInstanceService.buildById(jobId);
    assertThat(reloadedJobInstance.getState(), is(JobState.Completed));
    assertThat(reloadedJobInstance.getResult(), is(JobResult.Failed));
    assertThat(serverHealthService.filterByScope(HealthStateScope.forJob("last", "stage", "job-one")).size(), is(1));
    ServerHealthState error = serverHealthService.filterByScope(HealthStateScope.forJob("last", "stage", "job-one")).get(0);
    assertThat(error, is(ServerHealthState.error("Cannot load job 'last/" + pipeline.getCounter() + "/stage/1/job-one' because material " + onDirTwo + " was not found in config.", "Job for pipeline 'last/" + pipeline.getCounter() + "/stage/1/job-one' has been failed as one or more material configurations were either changed or removed.", HealthStateType.general(HealthStateScope.forJob("last", "stage", "job-one")))));
    DateTime expiryTime = (DateTime) ReflectionUtil.getField(error, "expiryTime");
    assertThat(expiryTime.toDate().after(currentTime), is(true));
    assertThat(expiryTime.toDate().before(new Date(System.currentTimeMillis() + 5 * 60 * 1000 + 1)), is(true));
    String logText = FileUtils.readFileToString(consoleService.consoleLogArtifact(reloadedJobInstance.getIdentifier()), UTF_8);
    assertThat(logText, containsString("Cannot load job 'last/" + pipeline.getCounter() + "/stage/1/job-one' because material " + onDirTwo + " was not found in config."));
    assertThat(logText, containsString("Job for pipeline 'last/" + pipeline.getCounter() + "/stage/1/job-one' has been failed as one or more material configurations were either changed or removed."));
}
Also used : StaleMaterialsOnBuildCause(com.thoughtworks.go.server.materials.StaleMaterialsOnBuildCause) TransactionStatus(org.springframework.transaction.TransactionStatus) Matchers.containsString(org.hamcrest.Matchers.containsString) Date(java.util.Date) IllegalArtifactLocationException(com.thoughtworks.go.domain.exception.IllegalArtifactLocationException) IOException(java.io.IOException) DateTime(org.joda.time.DateTime) TransactionCallback(org.springframework.transaction.support.TransactionCallback) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

Aggregations

SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)72 Test (org.junit.Test)54 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)22 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)12 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)11 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)11 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)8 GoCipher (com.thoughtworks.go.security.GoCipher)8 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)7 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)6 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)6 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)6 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)6 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 SvnCommand (com.thoughtworks.go.domain.materials.svn.SvnCommand)4 SvnTestRepo (com.thoughtworks.go.helper.SvnTestRepo)3 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)2 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)2 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)2