use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveSvnMaterials.
@Test
public void shouldStoreAndRetrieveSvnMaterials() throws SQLException {
SvnMaterial svnMaterial = svnMaterial("svnUrl", "folder");
PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
pipelineConfig.setMaterialConfigs(new MaterialConfigs(svnMaterial.config()));
MaterialRevisions materialRevisions = new MaterialRevisions();
materialRevisions.addRevision(svnMaterial, ModificationsMother.multipleModificationList());
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
assertNotInserted(pipeline.getId());
savePipeline(pipeline);
Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
final Materials materials = pipelineFromDB.getMaterials();
assertThat(materials.get(0), is(svnMaterial));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldFindPipelineThatPassedForStageAcrossStageReruns.
@Test
public void shouldFindPipelineThatPassedForStageAcrossStageReruns() throws Exception {
PipelineConfig config = PipelineMother.createPipelineConfig("pipeline", new MaterialConfigs(MaterialConfigsMother.hgMaterialConfig()), "firstStage", "secondStage");
Pipeline pipeline0 = dbHelper.newPipelineWithAllStagesPassed(config);
dbHelper.updateNaturalOrder(pipeline0.getId(), 4.0);
Pipeline pipeline1 = dbHelper.newPipelineWithFirstStagePassed(config);
Stage stage = dbHelper.scheduleStage(pipeline1, config.get(1));
dbHelper.failStage(stage);
stage = dbHelper.scheduleStage(pipeline1, config.get(1));
dbHelper.passStage(stage);
dbHelper.updateNaturalOrder(pipeline1.getId(), 5.0);
Stage passedStageRerun = StageMother.scheduledStage("pipeline", pipeline1.getCounter(), "secondStage", 2, "job");
passedStageRerun = stageDao.saveWithJobs(pipeline1, passedStageRerun);
dbHelper.passStage(passedStageRerun);
Pipeline pipeline5 = dbHelper.newPipelineWithFirstStagePassed(config);
stage = dbHelper.scheduleStage(pipeline5, config.get(1));
dbHelper.failStage(stage);
dbHelper.updateNaturalOrder(pipeline5.getId(), 9.0);
Pipeline pipeline6 = dbHelper.newPipelineWithFirstStagePassed(config);
stage = dbHelper.scheduleStage(pipeline6, config.get(1));
dbHelper.failStage(stage);
dbHelper.updateNaturalOrder(pipeline6.getId(), 10.0);
Pipeline pipeline = pipelineDao.findEarlierPipelineThatPassedForStage("pipeline", "secondStage", 10.0);
assertThat(pipeline.getId(), is(pipeline1.getId()));
assertThat(pipeline.getNaturalOrder(), is(5.0));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class JobRunnerTest method getWork.
private BuildWork getWork(JobConfig jobConfig) {
CruiseConfig config = new BasicCruiseConfig();
config.server().setArtifactsDir("logs");
String stageName = "mingle";
String pipelineName = "pipeline1";
config.addPipeline(BasicPipelineConfigs.DEFAULT_GROUP, new PipelineConfig(new CaseInsensitiveString(pipelineName), new MaterialConfigs(), new StageConfig(new CaseInsensitiveString(stageName), new JobConfigs(jobConfig))));
String pipelineLabel = "100";
JobPlan jobPlan = JobInstanceMother.createJobPlan(jobConfig, new JobIdentifier(pipelineName, -2, pipelineLabel, stageName, "100", JOB_PLAN_NAME, 0L), new DefaultSchedulingContext());
jobPlan.setFetchMaterials(true);
jobPlan.setCleanWorkingDir(false);
List<Builder> builder = BuilderMother.createBuildersAssumingAllExecTasks(config, pipelineName, stageName, JOB_PLAN_NAME);
BuildAssignment buildAssignment = BuildAssignment.create(jobPlan, BuildCause.createWithEmptyModifications(), builder, new File(CruiseConfig.WORKING_BASE_DIR + pipelineName));
return new BuildWork(buildAssignment);
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class ApprovalTest method shouldValidateTree.
@Test
public void shouldValidateTree() {
Approval approval = new Approval(new AuthConfig(new AdminRole(new CaseInsensitiveString("role"))));
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
cruiseConfig.server().security().adminsConfig().addRole(new AdminRole(new CaseInsensitiveString("super-admin")));
PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("p1"), new MaterialConfigs());
cruiseConfig.addPipeline("g1", pipelineConfig);
assertThat(approval.validateTree(PipelineConfigSaveValidationContext.forChain(true, "g1", cruiseConfig, pipelineConfig)), is(false));
assertThat(approval.getAuthConfig().errors().isEmpty(), is(false));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineHistoryMother method pipeline.
public static PipelineModel pipeline() {
PipelineModel pipelineModel = new PipelineModel("pipe1", true, true, PipelinePauseInfo.notPaused());
MaterialRevisions materialRevisions = ModificationsMother.createHgMaterialRevisions();
PipelineInstanceModel instanceModel = PipelineInstanceModel.createPipeline("pipe1", -1, "label1", BuildCause.createWithModifications(materialRevisions, "foo-bar"), new StageInstanceModels());
instanceModel.setMaterialConfigs(new MaterialConfigs(materialRevisions.getMaterialRevision(0).getMaterial().config()));
instanceModel.setLatestRevisions(materialRevisions);
pipelineModel.addPipelineInstance(instanceModel);
return pipelineModel;
}
Aggregations