Search in sources :

Example 1 with BuildLogElement

use of com.thoughtworks.go.domain.BuildLogElement in project gocd by gocd.

the class BuilderTest method shouldNotBuildIfTheJobIsCancelled.

@Test
public void shouldNotBuildIfTheJobIsCancelled() throws Exception {
    CommandBuilder builder = new CommandBuilder("echo", "", new File("."), new RunIfConfigs(FAILED), new StubBuilder(), "");
    builder.build(new BuildLogElement(), PASSED, goPublisher, environmentVariableContext, null);
    assertThat(goPublisher.getMessage(), is(""));
}
Also used : BuildLogElement(com.thoughtworks.go.domain.BuildLogElement) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) File(java.io.File) Test(org.junit.Test)

Example 2 with BuildLogElement

use of com.thoughtworks.go.domain.BuildLogElement in project gocd by gocd.

the class Builders method build.

public JobResult build(EnvironmentVariableContext environmentVariableContext) {
    JobResult result = JobResult.Passed;
    for (Builder builder : builders) {
        if (cancelStarted) {
            return JobResult.Cancelled;
        }
        synchronized (this) {
            currentBuilder = builder;
        }
        BuildLogElement buildLogElement = new BuildLogElement();
        try {
            builder.build(buildLogElement, RunIfConfig.fromJobResult(result.toLowerCase()), goPublisher, environmentVariableContext, taskExtension);
        } catch (Exception e) {
            result = JobResult.Failed;
        }
        buildLog.addContent(buildLogElement.getElement());
    }
    synchronized (this) {
        currentBuilder = new NullBuilder();
    }
    if (cancelStarted) {
        return JobResult.Cancelled;
    }
    return result;
}
Also used : BuildLogElement(com.thoughtworks.go.domain.BuildLogElement) JobResult(com.thoughtworks.go.domain.JobResult) Builder(com.thoughtworks.go.domain.builder.Builder) NullBuilder(com.thoughtworks.go.domain.builder.NullBuilder) NullBuilder(com.thoughtworks.go.domain.builder.NullBuilder)

Example 3 with BuildLogElement

use of com.thoughtworks.go.domain.BuildLogElement in project gocd by gocd.

the class Builder method cancel.

public void cancel(DefaultGoPublisher publisher, EnvironmentVariableContext environmentVariableContext, TaskExtension taskExtension) {
    publisher.consumeLineWithPrefix("Start to execute cancel task: " + cancelBuilder.getDescription());
    try {
        cancelBuilder.build(new BuildLogElement(), publisher, environmentVariableContext, taskExtension);
        publisher.consumeLineWithPrefix("Task is cancelled");
    } catch (Exception e) {
        LOGGER.error("", e);
    }
}
Also used : BuildLogElement(com.thoughtworks.go.domain.BuildLogElement) CruiseControlException(com.thoughtworks.go.util.command.CruiseControlException)

Aggregations

BuildLogElement (com.thoughtworks.go.domain.BuildLogElement)3 JobResult (com.thoughtworks.go.domain.JobResult)1 RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)1 Builder (com.thoughtworks.go.domain.builder.Builder)1 NullBuilder (com.thoughtworks.go.domain.builder.NullBuilder)1 CruiseControlException (com.thoughtworks.go.util.command.CruiseControlException)1 File (java.io.File)1 Test (org.junit.Test)1