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);
}
}
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"));
}
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"));
}
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());
}
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;
}
Aggregations