Search in sources :

Example 11 with Task

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

the class OnCancelConfig method setConfigAttributes.

private void setConfigAttributes(Object attributes, TaskFactory taskFactory) {
    Map attributeMap = (Map) attributes;
    Task task = taskFactory.taskInstanceFor((String) attributeMap.get(ON_CANCEL_OPTIONS));
    task.setConfigAttributes(attributeMap.get(task.getTaskType() + "OnCancel"));
    this.task = task;
}
Also used : KillAllChildProcessTask(com.thoughtworks.go.domain.KillAllChildProcessTask) Task(com.thoughtworks.go.domain.Task) NullTask(com.thoughtworks.go.domain.NullTask) Map(java.util.Map)

Example 12 with Task

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

the class PipelineConfigTreeValidator method validateFetchTasksForOtherPipelines.

private void validateFetchTasksForOtherPipelines(PipelineConfigSaveValidationContext validationContext, PipelineConfig downstreamPipeline) {
    for (StageConfig stageConfig : downstreamPipeline.getStages()) {
        for (JobConfig jobConfig : stageConfig.getJobs()) {
            for (Task task : jobConfig.getTasks()) {
                if (task instanceof FetchTask) {
                    FetchTask fetchTask = (FetchTask) task;
                    if (fetchTask.getPipelineNamePathFromAncestor() != null && !StringUtils.isBlank(CaseInsensitiveString.str(fetchTask.getPipelineNamePathFromAncestor().getPath())) && fetchTask.getPipelineNamePathFromAncestor().pathIncludingAncestor().contains(pipelineConfig.name())) {
                        fetchTask = new Cloner().deepClone(fetchTask);
                        fetchTask.validateTask(validationContext.withParent(downstreamPipeline).withParent(stageConfig).withParent(jobConfig));
                        List<String> allErrors = fetchTask.errors().getAll();
                        for (String error : allErrors) {
                            pipelineConfig.errors().add("base", error);
                        }
                    }
                }
            }
        }
    }
}
Also used : Task(com.thoughtworks.go.domain.Task) Cloner(com.rits.cloning.Cloner)

Example 13 with Task

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

the class GoConfigMigrationIntegrationTest method shouldTrimLeadingAndTrailingWhitespaceFromCommands_asPartOfMigration73.

@Test
public void shouldTrimLeadingAndTrailingWhitespaceFromCommands_asPartOfMigration73() throws Exception {
    String configXml = "<cruise schemaVersion='72'>" + "  <pipelines group='first'>" + "    <pipeline name='Test'>" + "      <materials>" + "        <hg url='../manual-testing/ant_hg/dummy' />" + "      </materials>" + "      <stage name='Functional'>" + "        <jobs>" + "          <job name='Functional'>" + "            <tasks>" + "              <exec command='  c:\\program files\\cmd.exe    ' args='arguments' />" + "            </tasks>" + "           </job>" + "        </jobs>" + "      </stage>" + "    </pipeline>" + "  </pipelines>" + "</cruise>";
    CruiseConfig migratedConfig = migrateConfigAndLoadTheNewConfig(configXml, 72);
    Task task = migratedConfig.tasksForJob("Test", "Functional", "Functional").get(0);
    assertThat(task, is(instanceOf(ExecTask.class)));
    assertThat(task, is(new ExecTask("c:\\program files\\cmd.exe", "arguments", (String) null)));
}
Also used : Task(com.thoughtworks.go.domain.Task) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 14 with Task

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

the class GoConfigMigrationIntegrationTest method shouldTrimLeadingAndTrailingWhitespaceFromCommandsInTemplates_asPartOfMigration73.

@Test
public void shouldTrimLeadingAndTrailingWhitespaceFromCommandsInTemplates_asPartOfMigration73() throws Exception {
    String configXml = "<cruise schemaVersion='72'>" + "  <pipelines group='first'>" + "    <pipeline name='Test' template='test_template'>" + "      <materials>" + "        <hg url='../manual-testing/ant_hg/dummy' />" + "      </materials>" + "     </pipeline>" + "  </pipelines>" + "  <templates>" + "    <pipeline name='test_template'>" + "      <stage name='Functional'>" + "        <jobs>" + "          <job name='Functional'>" + "            <tasks>" + "              <exec command='  c:\\program files\\cmd.exe    ' args='arguments' />" + "            </tasks>" + "           </job>" + "        </jobs>" + "      </stage>" + "    </pipeline>" + "  </templates>" + "</cruise>";
    CruiseConfig migratedConfig = migrateConfigAndLoadTheNewConfig(configXml, 72);
    Task task = migratedConfig.tasksForJob("Test", "Functional", "Functional").get(0);
    assertThat(task, is(instanceOf(ExecTask.class)));
    assertThat(task, is(new ExecTask("c:\\program files\\cmd.exe", "arguments", (String) null)));
}
Also used : Task(com.thoughtworks.go.domain.Task) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 15 with Task

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

the class TaskViewServiceTest method shouldGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOn.

@Test
public void shouldGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOn() {
    List<Class<? extends Task>> taskClasses = taskImplementations();
    taskClasses.add(FetchPluggableArtifactTask.class);
    when(featureToggleService.isToggleOn(Toggles.ARTIFACT_EXTENSION_KEY)).thenReturn(true);
    when(registry.implementersOf(Task.class)).thenReturn(taskClasses);
    when(registry.getViewModelFor(new FetchPluggableArtifactTask(), "new")).thenReturn(viewModel(new FetchPluggableArtifactTask()));
    when(registry.getViewModelFor(new ExecTask(), "new")).thenReturn(new TaskViewModel(new ExecTask(), ""));
    List<PluggableViewModel> taskViewModels = taskViewService.getTaskViewModels();
    assertThat(taskViewModels.size(), is(4));
    assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new ExecTask(), "")));
    assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new FetchPluggableArtifactTask(), "")));
}
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) PluggableViewModel(com.thoughtworks.go.plugins.presentation.PluggableViewModel) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) Test(org.junit.Test)

Aggregations

Task (com.thoughtworks.go.domain.Task)15 Test (org.junit.Test)9 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)8 ExecTask (com.thoughtworks.go.config.ExecTask)6 AntTask (com.thoughtworks.go.config.AntTask)5 FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)5 FetchTask (com.thoughtworks.go.config.FetchTask)5 PluggableViewModel (com.thoughtworks.go.plugins.presentation.PluggableViewModel)4 TaskViewModel (com.thoughtworks.go.presentation.TaskViewModel)4 KillAllChildProcessTask (com.thoughtworks.go.domain.KillAllChildProcessTask)2 NullTask (com.thoughtworks.go.domain.NullTask)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Cloner (com.rits.cloning.Cloner)1 BuildTask (com.thoughtworks.go.config.BuildTask)1 Tasks (com.thoughtworks.go.config.Tasks)1 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)1 Pipeline (com.thoughtworks.go.domain.Pipeline)1 Builder (com.thoughtworks.go.domain.builder.Builder)1