use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.
the class ScheduledPipelineLoader method pipelineWithPasswordAwareBuildCauseByBuildId.
// TODO: Do we need to do this differently than PipelineService#fullPipeline?
public Pipeline pipelineWithPasswordAwareBuildCauseByBuildId(final long buildId) {
Pipeline pipeline = pipelineDao.pipelineWithMaterialsAndModsByBuildId(buildId);
MaterialRevisions scheduledRevs = pipeline.getBuildCause().getMaterialRevisions();
MaterialConfigs knownMaterials = knownMaterials(pipeline, scheduledRevs);
for (MaterialRevision materialRevision : scheduledRevs) {
MaterialConfig materialConfig = materialFrom(knownMaterials, materialRevision);
Material usedMaterial = materialRevision.getMaterial();
if (materialConfig == null) {
final JobInstance jobInstance = jobInstanceService.buildByIdWithTransitions(buildId);
scheduleService.failJob(jobInstance);
final String message = "Cannot load job '" + jobInstance.buildLocator() + "' because material " + usedMaterial.config() + " was not found in config.";
final String description = "Job for pipeline '" + jobInstance.buildLocator() + "' has been failed as one or more material configurations were either changed or removed.";
transactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
final ServerHealthState error = ServerHealthState.error(message, description, HealthStateType.general(HealthStateScope.forJob(jobInstance.getPipelineName(), jobInstance.getStageName(), jobInstance.getName())));
error.setTimeout(Timeout.FIVE_MINUTES);
serverHealthService.update(error);
appendToConsoleLog(jobInstance, message);
appendToConsoleLog(jobInstance, description);
}
});
throw new StaleMaterialsOnBuildCause(message);
}
usedMaterial.updateFromConfig(materialConfig);
}
return pipeline;
}
use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.
the class ServerHealthRequestProcessor method replaceServerHealthMessages.
private void replaceServerHealthMessages(String errorMessageTitle, HealthStateScope scope, List<PluginHealthMessage> pluginHealthMessages) {
serverHealthService.removeByScope(scope);
for (int index = 0; index < pluginHealthMessages.size(); index++) {
PluginHealthMessage pluginHealthMessage = pluginHealthMessages.get(index);
ServerHealthState state;
if (pluginHealthMessage.isWarning()) {
state = ServerHealthState.warning(errorMessageTitle, pluginHealthMessage.message(), HealthStateType.withSubkey(scope, "message_" + index));
} else {
state = ServerHealthState.error(errorMessageTitle, pluginHealthMessage.message(), HealthStateType.withSubkey(scope, "message_" + index));
}
serverHealthService.update(state);
}
}
use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.
the class DiskSpaceOperationResult method error.
public ServerHealthState error(String message, String description, HealthStateType type) {
ServerHealthState state = ServerHealthState.error(message, description, type);
serverHealthService.update(state);
canContinue = false;
return state;
}
use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.
the class ServerHealthInformationProvider method asJson.
@Override
public Map<String, Object> asJson() {
LinkedHashMap<String, Object> json = new LinkedHashMap<>();
ServerHealthStates allLogs = service.logs();
json.put("Messages Count", allLogs.size());
ArrayList<Map<String, String>> messages = new ArrayList<>();
for (ServerHealthState log : allLogs) {
messages.add(log.asJson());
}
json.put("Messages", messages);
return json;
}
use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.
the class ManualBuild method canProduce.
public void canProduce(PipelineConfig pipelineConfig, SchedulingCheckerService schedulingChecker, ServerHealthService serverHealthService, OperationResult operationResult) {
schedulingChecker.canTriggerManualPipeline(pipelineConfig, CaseInsensitiveString.str(username.getUsername()), operationResult);
if (!operationResult.canContinue()) {
ServerHealthState serverHealthState = operationResult.getServerHealthState();
LOGGER.info("'{}' because '{}'", serverHealthState.getMessage(), serverHealthState.getDescription());
serverHealthService.update(serverHealthState);
}
}
Aggregations