Search in sources :

Example 11 with RunIfConfigs

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

the class ConfigConverterTest method shouldMigrateRakeTaskToCR.

@Test
void shouldMigrateRakeTaskToCR() {
    RakeTask rakeTask = new RakeTask();
    rakeTask.setBuildFile("Rakefile.rb");
    rakeTask.setWorkingDirectory("src");
    rakeTask.setTarget("build");
    rakeTask.setConditions(new RunIfConfigs(RunIfConfig.FAILED));
    CRBuildTask result = (CRBuildTask) configConverter.taskToCRTask(rakeTask);
    assertThat(result.getType()).isEqualTo(CRBuildFramework.rake);
    assertThat(result.getBuildFile()).isEqualTo("Rakefile.rb");
    assertThat(result.getTarget()).isEqualTo("build");
    assertThat(result.getWorkingDirectory()).isEqualTo("src");
    assertThat(result.getRunIf()).isEqualTo(CRRunIf.failed);
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) Test(org.junit.jupiter.api.Test)

Example 12 with RunIfConfigs

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

the class BaseTaskRepresenter method fromJSON.

public static AbstractTask fromJSON(JsonReader jsonReader, AbstractTask task) {
    RunIfConfigs runIfConfigs = new RunIfConfigs();
    jsonReader.readArrayIfPresent("run_if", configs -> {
        configs.forEach(runIfConfig -> {
            runIfConfigs.add(new RunIfConfig(runIfConfig.getAsString()));
        });
    });
    task.setConditions(runIfConfigs);
    jsonReader.optJsonObject("on_cancel").ifPresent(onCancelReader -> {
        OnCancelConfig onCancelConfig = OnCancelRepresenter.fromJSON(jsonReader.readJsonObject("on_cancel"));
        task.setOnCancelConfig(onCancelConfig);
    });
    return task;
}
Also used : RunIfConfig(com.thoughtworks.go.config.RunIfConfig) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) OnCancelConfig(com.thoughtworks.go.config.OnCancelConfig)

Example 13 with RunIfConfigs

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

the class BuilderTest method shouldReportErrorWhenCancelCommandDoesNotExist.

@Test
@DisabledOnOs(OS.WINDOWS)
void shouldReportErrorWhenCancelCommandDoesNotExist() {
    StubBuilder stubBuilder = new StubBuilder();
    CommandBuilder cancelBuilder = new CommandBuilder("echo2", "cancel task", new File("."), new RunIfConfigs(FAILED), stubBuilder, "");
    CommandBuilder builder = new CommandBuilder("echo", "normal task", new File("."), new RunIfConfigs(FAILED), cancelBuilder, "");
    builder.cancel(goPublisher, new EnvironmentVariableContext(), null, null, "utf-8");
    assertThat(goPublisher.getMessage()).contains("Error happened while attempting to execute 'echo2 cancel task'");
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) File(java.io.File) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 14 with RunIfConfigs

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

the class BuildersTest method shouldNotSetAsCurrentBuilderIfNotRun.

@Test
public void shouldNotSetAsCurrentBuilderIfNotRun() throws Exception {
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    Builder builder = new CommandBuilder("echo", "", new File("."), new RunIfConfigs(FAILED), null, "");
    Builders builders = new Builders(Collections.singletonList(builder), null, null, null, null);
    builders.setIsCancelled(true);
    builders.build(environmentVariableContext, "utf-8");
    Builders expected = new Builders(Collections.singletonList(builder), null, null, null, null);
    expected.setIsCancelled(true);
    assertThat(builders, is(expected));
}
Also used : CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) StubBuilder(com.thoughtworks.go.domain.builder.StubBuilder) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 15 with RunIfConfigs

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

the class BuildersTest method shouldNotCancelAnythingIfAllBuildersHaveRun.

@Test
public void shouldNotCancelAnythingIfAllBuildersHaveRun() throws Exception {
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    Builder builder = new StubBuilder(new RunIfConfigs(ANY));
    Builders builders = new Builders(Collections.singletonList(builder), new StubGoPublisher(), null, null, null);
    builders.build(environmentVariableContext, "utf-8");
    builders.cancel(environmentVariableContext, "utf-8");
}
Also used : StubGoPublisher(com.thoughtworks.go.domain.StubGoPublisher) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) StubBuilder(com.thoughtworks.go.domain.builder.StubBuilder) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) StubBuilder(com.thoughtworks.go.domain.builder.StubBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)29 Test (org.junit.jupiter.api.Test)22 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)10 File (java.io.File)9 Test (org.junit.Test)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 OnCancelConfig (com.thoughtworks.go.config.OnCancelConfig)3 RunIfConfig (com.thoughtworks.go.config.RunIfConfig)3 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)3 StubBuilder (com.thoughtworks.go.domain.builder.StubBuilder)3 Gson (com.google.gson.Gson)2 StubGoPublisher (com.thoughtworks.go.domain.StubGoPublisher)2 Builder (com.thoughtworks.go.domain.builder.Builder)2 HgUrlArgument (com.thoughtworks.go.util.command.HgUrlArgument)2 RunIf (com.googlecode.junit.ext.RunIf)1 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)1 BuildLogElement (com.thoughtworks.go.domain.BuildLogElement)1 FetchArtifactEnvironmentVariable (com.thoughtworks.go.plugin.access.artifact.models.FetchArtifactEnvironmentVariable)1 ArtifactRequestProcessor (com.thoughtworks.go.remote.work.artifact.ArtifactRequestProcessor)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1