Search in sources :

Example 11 with ExecTask

use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.

the class TaskViewServiceTest method shouldGetViewModelsForBuiltinTasks.

@Test
public void shouldGetViewModelsForBuiltinTasks() {
    List<Class<? extends Task>> taskClasses = taskImplementations();
    when(registry.implementersOf(Task.class)).thenReturn(taskClasses);
    when(registry.getViewModelFor(new AntTask(), "new")).thenReturn(viewModel(new AntTask()));
    when(registry.getViewModelFor(new ExecTask(), "new")).thenReturn(new TaskViewModel(new ExecTask(), ""));
    List<PluggableViewModel> taskViewModels = taskViewService.getTaskViewModels();
    assertThat(taskViewModels.size(), is(3));
    assertThat(taskViewModels, hasItem((PluggableViewModel) viewModel(new AntTask())));
    assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new ExecTask(), "")));
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) Task(com.thoughtworks.go.domain.Task) FetchTask(com.thoughtworks.go.config.FetchTask) AntTask(com.thoughtworks.go.config.AntTask) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) TaskViewModel(com.thoughtworks.go.presentation.TaskViewModel) ExecTask(com.thoughtworks.go.config.ExecTask) AntTask(com.thoughtworks.go.config.AntTask) PluggableViewModel(com.thoughtworks.go.plugins.presentation.PluggableViewModel) Test(org.junit.Test)

Example 12 with ExecTask

use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.

the class ExecTaskTest method shouldUseConfiguredWorkingDirectory.

@Test
public void shouldUseConfiguredWorkingDirectory() throws Exception {
    File absoluteFile = new File("test").getAbsoluteFile();
    ExecTask task = new ExecTask("command", "arguments", absoluteFile.getAbsolutePath());
    assertThat(task.workingDirectory(), Matchers.is(absoluteFile.getPath()));
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) File(java.io.File) Test(org.junit.Test)

Example 13 with ExecTask

use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.

the class ExecTaskTest method shouldSupportMultipleArgs.

@Test
public void shouldSupportMultipleArgs() throws Exception {
    String xml = "<exec command='ls'>\n" + "  <arg>arg1</arg>\n" + "  <arg>arg2</arg>\n" + "</exec>";
    ExecTask execTask = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).fromXmlPartial(xml, ExecTask.class);
    assertThat(execTask.getArgList(), is(new Arguments(new Argument("arg1"), new Argument("arg2"))));
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) Argument(com.thoughtworks.go.config.Argument) ExecTask(com.thoughtworks.go.config.ExecTask) Arguments(com.thoughtworks.go.domain.config.Arguments) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 14 with ExecTask

use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.

the class BuilderMother method createBuildersAssumingAllExecTasks.

public static List<Builder> createBuildersAssumingAllExecTasks(CruiseConfig config, String pipelineName, String stageName, String jobName) {
    Tasks tasks = config.jobConfigByName(pipelineName, stageName, jobName, true).getTasks();
    ArrayList<Builder> builders = new ArrayList<>();
    for (Task task : tasks) {
        builders.add(builderFor((ExecTask) task));
    }
    return builders;
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) Task(com.thoughtworks.go.domain.Task) Tasks(com.thoughtworks.go.config.Tasks) Builder(com.thoughtworks.go.domain.builder.Builder) ExecTask(com.thoughtworks.go.config.ExecTask) ArrayList(java.util.ArrayList)

Example 15 with ExecTask

use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.

the class PipelineBean method getTasks.

public Tasks getTasks() {
    Tasks tasks = new Tasks();
    if ("ant".equals(builder)) {
        AntTask antTask = new AntTask();
        antTask.setTarget(this.target);
        antTask.setBuildFile(defaultString(StringUtils.isBlank(this.buildfile) ? "build.xml" : this.buildfile));
        tasks.add(antTask);
    } else if ("nant".equals(builder)) {
        NantTask nantTask = new NantTask();
        nantTask.setTarget(this.target);
        nantTask.setBuildFile(defaultString(StringUtils.isBlank(this.buildfile) ? "default.build" : this.buildfile));
        tasks.add(nantTask);
    } else if ("rake".equals(builder)) {
        RakeTask rakeTask = new RakeTask();
        rakeTask.setTarget(this.target);
        rakeTask.setBuildFile(StringUtils.isBlank(this.buildfile) ? null : this.buildfile);
        tasks.add(rakeTask);
    } else if ("exec".equals(builder)) {
        String trimmedCommand = StringUtils.defaultString(this.command).trim();
        String trimmedArguments = StringUtils.defaultString(this.arguments).trim();
        ExecTask execTask = new ExecTask(trimmedCommand, trimmedArguments, (String) null);
        tasks.add(execTask);
    }
    return tasks;
}
Also used : Tasks(com.thoughtworks.go.config.Tasks) RakeTask(com.thoughtworks.go.config.RakeTask) ExecTask(com.thoughtworks.go.config.ExecTask) AntTask(com.thoughtworks.go.config.AntTask) NantTask(com.thoughtworks.go.config.NantTask) StringUtils.defaultString(org.apache.commons.lang.StringUtils.defaultString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Aggregations

ExecTask (com.thoughtworks.go.config.ExecTask)19 Test (org.junit.Test)17 AntTask (com.thoughtworks.go.config.AntTask)9 PluggableViewModel (com.thoughtworks.go.plugins.presentation.PluggableViewModel)8 FetchTask (com.thoughtworks.go.config.FetchTask)7 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)5 Task (com.thoughtworks.go.domain.Task)5 FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)4 TasksTest (com.thoughtworks.go.domain.TasksTest)4 TaskViewModel (com.thoughtworks.go.presentation.TaskViewModel)4 Builder (com.thoughtworks.go.domain.builder.Builder)3 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)3 Tasks (com.thoughtworks.go.config.Tasks)2 File (java.io.File)2 RunIf (com.googlecode.junit.ext.RunIf)1 Argument (com.thoughtworks.go.config.Argument)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 ConfigCache (com.thoughtworks.go.config.ConfigCache)1 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)1 NantTask (com.thoughtworks.go.config.NantTask)1