Search in sources :

Example 1 with ConsoleOut

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);
    }
}
Also used : FileModelAndView(com.thoughtworks.go.server.web.FileModelAndView) ModelAndView(org.springframework.web.servlet.ModelAndView) FileNotFoundException(java.io.FileNotFoundException) ConsoleOut(com.thoughtworks.go.domain.ConsoleOut) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) HeaderConstraint(com.thoughtworks.go.server.security.HeaderConstraint) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) IllegalArtifactLocationException(com.thoughtworks.go.domain.exception.IllegalArtifactLocationException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with ConsoleOut

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));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ConsoleOut(com.thoughtworks.go.domain.ConsoleOut) Test(org.junit.Test)

Aggregations

ConsoleOut (com.thoughtworks.go.domain.ConsoleOut)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 IllegalArtifactLocationException (com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)1 HeaderConstraint (com.thoughtworks.go.server.security.HeaderConstraint)1 FileModelAndView (com.thoughtworks.go.server.web.FileModelAndView)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Test (org.junit.Test)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1