Search in sources :

Example 6 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class LongWorkCreator method getWork.

public Work getWork() {
    try {
        CruiseConfig config = GoConfigMother.pipelineHavingJob(PIPELINE_NAME, STAGE_NAME, JOB_PLAN_NAME, ARTIFACT_FILE.getAbsolutePath(), ARTIFACT_FOLDER.getAbsolutePath());
        BuildCause buildCause = BuildCause.createWithEmptyModifications();
        builder = new ArrayList<>();
        builder.add(new SleepBuilder());
        JobPlan instance = toBuildInstance(config);
        BuildAssignment buildAssignment = BuildAssignment.create(instance, buildCause, builder, new File(CruiseConfig.WORKING_BASE_DIR + PIPELINE_NAME));
        return new BuildWork(buildAssignment);
    } catch (Exception e) {
        throw bomb(e);
    }
}
Also used : JobPlan(com.thoughtworks.go.domain.JobPlan) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) 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)

Example 7 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class ModificationBuildCauseTest method shouldReturnBuildCauseMessage.

@Test
public void shouldReturnBuildCauseMessage() {
    MaterialRevisions revisions = new MaterialRevisions();
    Modification modification = new Modification(new Date(), "pipelineName/123/stageName/1", "MOCK_LABEL-12", null);
    revisions.addRevision(new DependencyMaterial(new CaseInsensitiveString("cruise"), new CaseInsensitiveString("dev")), modification);
    BuildCause modificationBuildCause = BuildCause.createWithModifications(revisions, "");
    String message = modificationBuildCause.getBuildCauseMessage();
    assertThat(message, containsString("triggered by pipelineName/123/stageName/1"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 8 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class MessageTest method encodeAndDecodeAssignWorkWithDifferentBuilders.

@Test
public void encodeAndDecodeAssignWorkWithDifferentBuilders() throws Exception {
    File workingDir = new File(CruiseConfig.WORKING_BASE_DIR + "pipelineName");
    Materials materials = MaterialsMother.defaultMaterials();
    MaterialRevisions revisions = ModificationsMother.modifyOneFile(materials, ModificationsMother.nextRevision());
    BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
    List<Builder> builder = new ArrayList<>();
    builder.add(new CommandBuilder("command", "args", workingDir, new RunIfConfigs(), new NullBuilder(), "desc"));
    builder.add(new BuilderForKillAllChildTask());
    builder.add(new CommandBuilderWithArgList("command", new String[] { "arg1", "arg2" }, workingDir, new RunIfConfigs(), new NullBuilder(), "desc"));
    builder.add(new FetchArtifactBuilder(new RunIfConfigs(), new NullBuilder(), "desc", jobPlan().getIdentifier(), "srcdir", "dest", new FileHandler(workingDir, "src"), new ChecksumFileHandler(workingDir)));
    BuildAssignment assignment = BuildAssignment.create(jobPlan(), buildCause, builder, workingDir);
    BuildWork work = new BuildWork(assignment);
    byte[] msg = MessageEncoding.encodeMessage(new Message(Action.assignWork, MessageEncoding.encodeWork(work)));
    Message decodedMsg = MessageEncoding.decodeMessage(new ByteArrayInputStream(msg));
    BuildWork decodedWork = (BuildWork) MessageEncoding.decodeWork(decodedMsg.getData());
    assertThat(decodedWork.getAssignment().getPlan().getPipelineName(), is("pipelineName"));
}
Also used : Materials(com.thoughtworks.go.config.materials.Materials) ArrayList(java.util.ArrayList) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) BuildWork(com.thoughtworks.go.remote.work.BuildWork) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) ByteArrayInputStream(java.io.ByteArrayInputStream) File(java.io.File) Test(org.junit.Test)

Example 9 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class BuildCauseHandlerCallback method setParameter.

public void setParameter(ParameterSetter parameterSetter, Object parameter) throws SQLException {
    BuildCause buildCause = (BuildCause) parameter;
    parameterSetter.setString(buildCause.toDbString());
}
Also used : BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 10 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class PipelineSqlMapDao method findBuildCauseOfPipelineByNameAndCounter.

public BuildCause findBuildCauseOfPipelineByNameAndCounter(String name, int counter) {
    String cacheKey = cacheKeyForBuildCauseByNameAndCounter(name, counter);
    BuildCause buildCause = (BuildCause) goCache.get(cacheKey);
    if (buildCause == null) {
        synchronized (cacheKey) {
            buildCause = (BuildCause) goCache.get(cacheKey);
            if (buildCause == null) {
                Pipeline pipeline = findPipelineByNameAndCounter(name, counter);
                if (pipeline == null) {
                    throw new PipelineNotFoundException(String.format("Pipeline %s with counter %d was not found", name, counter));
                }
                loadMaterialRevisions(pipeline);
                buildCause = pipeline.getBuildCause();
                goCache.put(cacheKey, buildCause);
            }
        }
    }
    return buildCause;
}
Also used : PipelineNotFoundException(com.thoughtworks.go.config.PipelineNotFoundException) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Aggregations

BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)142 Test (org.junit.Test)108 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)35 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)30 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)29 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)27 TimeProvider (com.thoughtworks.go.util.TimeProvider)22 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 Modification (com.thoughtworks.go.domain.materials.Modification)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)15 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)14 Date (java.util.Date)13 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)10 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)10 Username (com.thoughtworks.go.server.domain.Username)10