use of com.thoughtworks.go.domain.ConsoleOut in project gocd by gocd.
the class ArtifactsController method consoleout.
/* Other URLs */
@RequestMapping(value = "/**/consoleout.json", method = RequestMethod.GET)
public ModelAndView consoleout(@RequestParam("pipelineName") String pipelineName, @RequestParam("pipelineLabel") String counterOrLabel, @RequestParam("stageName") String stageName, @RequestParam("buildName") String buildName, @RequestParam(value = "stageCounter", required = false) String stageCounter, @RequestParam(value = "startLineNumber", required = false) Integer start) throws Exception {
int startLine = start == null ? 0 : start;
try {
JobIdentifier identifier = restfulService.findJob(pipelineName, counterOrLabel, stageName, stageCounter, buildName);
ConsoleOut consoleOut = consoleService.getConsoleOut(identifier, startLine);
return new ModelAndView(new ConsoleOutView(consoleOut.calculateNextStart(), consoleOut.output()));
} catch (FileNotFoundException e) {
return new ModelAndView(new ConsoleOutView(0, ""));
} catch (Exception e) {
return buildNotFound(pipelineName, counterOrLabel, stageName, stageCounter, buildName);
}
}
use of com.thoughtworks.go.domain.ConsoleOut in project gocd by gocd.
the class ConsoleServiceTest method shouldReturnConsoleUpdates.
@Test
public void shouldReturnConsoleUpdates() throws IOException {
String separator = getProperty("line.separator");
String output = "line1" + separator + "line2" + separator + "line3";
ByteArrayInputStream stream = new ByteArrayInputStream(output.getBytes());
ConsoleOut consoleOut = service.getConsoleOut(0, stream);
assertThat(consoleOut.output(), is(output + separator));
assertThat(consoleOut.calculateNextStart(), is(3));
output += separator + "line4" + separator + "line5";
stream = new ByteArrayInputStream(output.getBytes());
consoleOut = service.getConsoleOut(3, stream);
assertThat(consoleOut.output(), is("line4" + separator + "line5" + separator));
assertThat(consoleOut.calculateNextStart(), is(5));
}
Aggregations