use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineOperationsControllerV1Delegate method getScheduleOptions.
private PipelineScheduleOptions getScheduleOptions(Request req) {
if (StringUtils.isBlank(req.body())) {
return new PipelineScheduleOptions();
}
GsonTransformer gsonTransformer = GsonTransformer.getInstance();
JsonReader jsonReader = gsonTransformer.jsonReaderFrom(req.body());
return PipelineScheduleOptionsRepresenter.fromJSON(jsonReader);
}
use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineScheduleOptionsRepresenter method fromJSON.
public static PipelineScheduleOptions fromJSON(JsonReader jsonReader) {
PipelineScheduleOptions model = new PipelineScheduleOptions();
model.shouldPerformMDUBeforeScheduling(jsonReader.optBoolean("update_materials_before_scheduling").orElse(Boolean.TRUE));
jsonReader.readArrayIfPresent("materials", materials -> {
List<MaterialForScheduling> materialsForScheduling = new ArrayList<>();
materials.forEach(material -> materialsForScheduling.add(MaterialRevisionRepresenter.fromJSON(new JsonReader(material.getAsJsonObject()))));
model.setMaterials(materialsForScheduling);
});
jsonReader.readArrayIfPresent("environment_variables", environmentVariables -> {
EnvironmentVariablesConfig variables = new EnvironmentVariablesConfig();
environmentVariables.forEach(variable -> variables.add(EnvrionmentVariableRepresenter.fromJSON(new JsonReader(variable.getAsJsonObject()))));
model.setEnvironmentVariables(variables);
});
return model;
}
use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class ScheduleOptionsBuilder method build.
public ScheduleOptions build(HttpOperationResult result, String pipelineName, PipelineScheduleOptions pipelineScheduleOptions) {
ScheduleOptions scheduleOptions = new ScheduleOptions();
HealthStateType healthStateType = HealthStateType.general(HealthStateScope.forPipeline(pipelineName));
if (!goConfigService.hasPipelineNamed(new CaseInsensitiveString(pipelineName))) {
result.notFound(String.format("Pipeline '%s' not found.", pipelineName), "", healthStateType);
return null;
}
for (Builder builder : builders) {
if (result.canContinue())
builder.build(scheduleOptions, result, pipelineName, pipelineScheduleOptions, healthStateType);
}
return scheduleOptions;
}
use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineTriggerService method schedule.
public void schedule(String pipelineName, PipelineScheduleOptions pipelineScheduleOptions, Username username, final HttpOperationResult result) {
LOGGER.info("[Pipeline Schedule] [Requested] Manual trigger of pipeline '{}' requested by {}", pipelineName, CaseInsensitiveString.str(username.getUsername()));
ScheduleOptions scheduleOptions = new ScheduleOptionsBuilder(goConfigService).build(result, pipelineName, pipelineScheduleOptions);
if (result.canContinue()) {
LOGGER.info("[Pipeline Schedule] [Accepted] Manual trigger of pipeline '{}' accepted for user {}", pipelineName, CaseInsensitiveString.str(username.getUsername()));
buildCauseProducerService.manualSchedulePipeline(username, new CaseInsensitiveString(pipelineName), scheduleOptions, result);
LOGGER.info("[Pipeline Schedule] [Processed] Manual trigger of pipeline '{}' processed with result '{}'", pipelineName, result.getServerHealthState());
}
}
use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldNotPerformMDUIfScheduleOptionsIsSetToDisallowMDU.
@Test
public void shouldNotPerformMDUIfScheduleOptionsIsSetToDisallowMDU() throws IOException {
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
pipelineScheduleOptions.shouldPerformMDUBeforeScheduling(false);
String peggedRevision = "s2";
MaterialForScheduling material = new MaterialForScheduling(pipelineConfig.materialConfigs().first().getFingerprint(), peggedRevision);
pipelineScheduleOptions.getMaterials().add(material);
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(true));
assertThat(result.fullMessage(), is(String.format("Request to schedule pipeline %s accepted", pipelineName)));
assertThat(result.httpCode(), is(202));
assertThat(materialUpdateStatusNotifier.hasListenerFor(pipelineConfig), is(false));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(pipelineName);
assertNotNull(buildCause);
assertThat(buildCause.getApprover(), is(CaseInsensitiveString.str(admin.getUsername())));
assertThat(buildCause.getMaterialRevisions().findRevisionFor(pipelineConfig.materialConfigs().first()).getLatestRevisionString(), is("s2"));
assertThat(buildCause.getBuildCauseMessage(), is("Forced by admin1"));
assertTrue(buildCause.getVariables().isEmpty());
}
Aggregations