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;
}
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);
}
}
}
}
}
}
}
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)));
}
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)));
}
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(), "")));
}
Aggregations