Search in sources :

Example 26 with RunIfConfigs

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

the class MagicalGoConfigXmlWriterTest method shouldWriteConfigWithTaskExecutionConditions.

@Test
public void shouldWriteConfigWithTaskExecutionConditions() throws Exception {
    CruiseConfig cruiseConfig = ConfigMigrator.load(ConfigFileFixture.TASKS_WITH_CONDITION);
    xmlWriter.write(cruiseConfig, output, false);
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(output.toByteArray());
    CruiseConfig config = xmlLoader.loadConfigHolder(IOUtils.toString(inputStream, UTF_8)).config;
    JobConfig job = config.jobConfigByName("pipeline1", "mingle", "cardlist", true);
    assertThat(job.tasks().size(), is(2));
    assertThat(job.tasks().findFirstByType(AntTask.class).getConditions().get(0), is(new RunIfConfig("failed")));
    RunIfConfigs conditions = job.tasks().findFirstByType(NantTask.class).getConditions();
    assertThat(conditions.get(0), is(new RunIfConfig("failed")));
    assertThat(conditions.get(1), is(new RunIfConfig("any")));
    assertThat(conditions.get(2), is(new RunIfConfig("passed")));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) Test(org.junit.jupiter.api.Test)

Example 27 with RunIfConfigs

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

the class ConfigConverterTest method shouldMigrateNantTaskToCR.

@Test
void shouldMigrateNantTaskToCR() {
    NantTask nantTask = new NantTask();
    nantTask.setBuildFile("nant");
    nantTask.setWorkingDirectory("src");
    nantTask.setTarget("build");
    nantTask.setNantPath("path");
    nantTask.setConditions(new RunIfConfigs(RunIfConfig.PASSED));
    CRNantTask result = (CRNantTask) configConverter.taskToCRTask(nantTask);
    assertThat(result.getRunIf()).isEqualTo(CRRunIf.passed);
    assertThat(result.getBuildFile()).isEqualTo("nant");
    assertThat(result.getTarget()).isEqualTo("build");
    assertThat(result.getWorkingDirectory()).isEqualTo("src");
    assertThat(result.getNantPath()).isEqualTo("path");
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) Test(org.junit.jupiter.api.Test)

Example 28 with RunIfConfigs

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

the class ConfigConverterTest method shouldConvertExecTaskWhenCancelIsNotSpecifiedToCR.

@Test
void shouldConvertExecTaskWhenCancelIsNotSpecifiedToCR() {
    ExecTask execTask = new ExecTask("bash", new Arguments(new Argument("1"), new Argument("2")), "work");
    execTask.setConditions(new RunIfConfigs(RunIfConfig.FAILED));
    execTask.setTimeout(120L);
    CRExecTask result = (CRExecTask) configConverter.taskToCRTask(execTask);
    assertThat(result.getRunIf()).isEqualTo(CRRunIf.failed);
    assertThat(result.getCommand()).isEqualTo("bash");
    assertThat(result.getArguments()).contains("1");
    assertThat(result.getArguments()).contains("2");
    assertThat(result.getWorkingDirectory()).isEqualTo("work");
    assertThat(result.getTimeout()).isEqualTo(120L);
    assertThat(result.getOnCancel()).isNull();
}
Also used : HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) Test(org.junit.jupiter.api.Test)

Example 29 with RunIfConfigs

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

the class ConfigConverterTest method shouldConvertFetchArtifactTaskWhenSourceIsFileToCR.

@Test
void shouldConvertFetchArtifactTaskWhenSourceIsFileToCR() {
    FetchTask fetchTask = new FetchTask(new CaseInsensitiveString("upstream"), new CaseInsensitiveString("stage"), new CaseInsensitiveString("job"), "src", "dest");
    fetchTask.setConditions(new RunIfConfigs(RunIfConfig.FAILED));
    CRFetchArtifactTask result = (CRFetchArtifactTask) configConverter.taskToCRTask(fetchTask);
    assertThat(result.getRunIf()).isEqualTo(CRRunIf.failed);
    assertThat(result.getDestination()).isEqualTo("dest");
    assertThat(result.getJob()).isEqualTo("job");
    assertThat(result.getPipeline()).isEqualTo("upstream");
    assertThat(result.getSource()).isEqualTo("src");
    assertThat(result.sourceIsDirectory()).isFalse();
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) 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