use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldNotPerformMDUIfScheduleOptionsIsSetToDisallowMDU.
@Test
public void shouldNotPerformMDUIfScheduleOptionsIsSetToDisallowMDU() throws IOException {
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
pipelineScheduleOptions.shouldPerformMDUBeforeScheduling(false);
String peggedRevision = "s2";
MaterialForScheduling material = new MaterialForScheduling(pipelineConfig.materialConfigs().first().getFingerprint(), peggedRevision);
pipelineScheduleOptions.getMaterials().add(material);
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(true));
assertThat(result.fullMessage(), is(String.format("Request to schedule pipeline %s accepted", pipelineName)));
assertThat(result.httpCode(), is(202));
assertThat(materialUpdateStatusNotifier.hasListenerFor(pipelineConfig), is(false));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(pipelineName);
assertNotNull(buildCause);
assertThat(buildCause.getApprover(), is(CaseInsensitiveString.str(admin.getUsername())));
assertThat(buildCause.getMaterialRevisions().findRevisionFor(pipelineConfig.materialConfigs().first()).getLatestRevisionString(), is("s2"));
assertThat(buildCause.getBuildCauseMessage(), is("Forced by admin1"));
assertTrue(buildCause.getVariables().isEmpty());
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldScheduleAPipelineWithLatestRevisionOfAssociatedMaterial.
@Test
public void shouldScheduleAPipelineWithLatestRevisionOfAssociatedMaterial() {
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(true));
assertThat(result.fullMessage(), is(String.format("Request to schedule pipeline %s accepted", pipelineName)));
assertThat(result.httpCode(), is(202));
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(true));
materialUpdateStatusNotifier.onMessage(new MaterialUpdateSuccessfulMessage(svnMaterial, 1));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(pipelineName);
assertNotNull(buildCause);
assertThat(buildCause.getApprover(), is(CaseInsensitiveString.str(admin.getUsername())));
assertThat(buildCause.getMaterialRevisions().findRevisionFor(pipelineConfig.materialConfigs().first()).getLatestRevisionString(), is("s3"));
assertThat(buildCause.getBuildCauseMessage(), is("Forced by admin1"));
assertTrue(buildCause.getVariables().isEmpty());
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldResolveTriangleDependencyViaAutoBuild.
@Test
public void shouldResolveTriangleDependencyViaAutoBuild() throws Exception {
SystemEnvironment env = mock(SystemEnvironment.class);
when(env.enforceRevisionCompatibilityWithUpstream()).thenReturn(false);
int i = 0;
GitMaterial git = new GitMaterial("git");
String[] git_revs = { "g1" };
u.checkinInOrder(git, git_revs);
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(git));
ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("p6", u.m(p4), u.m(p5));
String p4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "g1");
String p4_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "g1");
String p5_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), p4_2);
String p4_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "g1");
String p4_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i), "g1");
MaterialRevisions given = u.mrs(u.mr(p4, true, p4_4), u.mr(p5, true, p5_1));
MaterialRevisions expected = u.mrs(u.mr(p4, false, p4_2), u.mr(p5, false, p5_1));
AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, p6.config.name().toString(), env, materialChecker);
pipelineTimeline.update();
BuildCause buildCause = autoBuild.onModifications(given, false, null);
assertThat(buildCause.getMaterialRevisions(), is(expected));
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class PipelineTest method shouldUseOldBuildCauseMessageIfThereIsNoneForThisPipeline.
@Test
public void shouldUseOldBuildCauseMessageIfThereIsNoneForThisPipeline() throws SQLException {
MaterialRevisions materialRevisions = ModificationsMother.multipleModifications();
BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, "");
Pipeline pipeline = new Pipeline("Test", buildCause);
assertThat(pipeline.getBuildCauseMessage(), not(Matchers.nullValue()));
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class DefaultWorkCreator method getWork.
public Work getWork(AgentIdentifier agentIdentifier) {
try {
CruiseConfig config = GoConfigMother.pipelineHavingJob(PIPELINE_NAME, STAGE_NAME, JOB_PLAN_NAME, ARTIFACT_FILE.getAbsolutePath(), ARTIFACT_FOLDER.getAbsolutePath());
BuildCause buildCause = BuildCause.createWithEmptyModifications();
BuildAssignment buildAssignment = BuildAssignment.create(toPlan(config), buildCause, new ArrayList<>(), new File("testdata/" + CruiseConfig.WORKING_BASE_DIR + STAGE_NAME), new EnvironmentVariableContext(), new ArtifactStores());
return new BuildWork(buildAssignment, "utf-8");
} catch (Exception e) {
throw bomb(e);
}
}
Aggregations