Search in sources :

Example 66 with BuildCause

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());
}
Also used : MaterialForScheduling(com.thoughtworks.go.server.domain.MaterialForScheduling) PipelineScheduleOptions(com.thoughtworks.go.server.domain.PipelineScheduleOptions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 67 with BuildCause

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());
}
Also used : PipelineScheduleOptions(com.thoughtworks.go.server.domain.PipelineScheduleOptions) MaterialUpdateSuccessfulMessage(com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 68 with BuildCause

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));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 69 with BuildCause

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()));
}
Also used : BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 70 with BuildCause

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);
    }
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) File(java.io.File) BuildWork(com.thoughtworks.go.remote.work.BuildWork) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) IOException(java.io.IOException) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Aggregations

BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)158 Test (org.junit.Test)115 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)33 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)32 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)31 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)31 TimeProvider (com.thoughtworks.go.util.TimeProvider)28 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)21 Modification (com.thoughtworks.go.domain.materials.Modification)21 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)16 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)16 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)14 Date (java.util.Date)14 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)13 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)12 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)11 Username (com.thoughtworks.go.server.domain.Username)10 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)10 Builder (com.thoughtworks.go.domain.builder.Builder)9