use of com.thoughtworks.go.serverhealth.HealthStateType in project gocd by gocd.
the class ManualPipelineChecker method check.
@Override
public void check(OperationResult result) {
HealthStateType type = HealthStateType.general(HealthStateScope.forPipeline(CaseInsensitiveString.str(pipelineConfig.name())));
if (pipelineConfig.isFirstStageManualApproval()) {
String message = String.format("Failed to trigger pipeline [%s]", pipelineConfig.name());
result.error(message, String.format("The first stage of pipeline \"%s\" has manual approval", pipelineConfig.name()), type);
} else {
result.success(type);
}
}
use of com.thoughtworks.go.serverhealth.HealthStateType in project gocd by gocd.
the class PipelineLockChecker method check.
@Override
public void check(OperationResult result) {
HealthStateType healthStateType = HealthStateType.general(HealthStateScope.forPipeline(pipelineName));
if (pipelineLockService.isLocked(pipelineName)) {
String message = format("Pipeline %s cannot be scheduled", pipelineName);
String description = format("Pipeline %s is locked as another instance of this pipeline is running.", pipelineName);
result.conflict(message, description, healthStateType);
} else {
result.success(healthStateType);
}
}
use of com.thoughtworks.go.serverhealth.HealthStateType in project gocd by gocd.
the class StageAuthorizationChecker method check.
@Override
public void check(OperationResult result) {
HealthStateType id = HealthStateType.general(HealthStateScope.forPipeline(pipelineName));
if (!securityService.hasOperatePermissionForStage(pipelineName, stageName, username)) {
String message = String.format("Failed to trigger pipeline [%s]", pipelineName);
result.forbidden(message, "User " + username + " does not have permission to schedule " + pipelineName + "/" + stageName, id);
} else {
result.success(id);
}
}
use of com.thoughtworks.go.serverhealth.HealthStateType in project gocd by gocd.
the class PipelineLockCheckerTest method shouldUpdateOperationResultAfterUnlockSoThatTheErrorMessageOnUIGoesAway.
@Test
public void shouldUpdateOperationResultAfterUnlockSoThatTheErrorMessageOnUIGoesAway() {
PipelineLockChecker pipelineLockChecker = new PipelineLockChecker("blahPipeline", pipelineLockService);
HealthStateType healthStateType = HealthStateType.general(HealthStateScope.forPipeline("blahPipeline"));
when(pipelineLockService.isLocked("blahPipeline")).thenReturn(true);
pipelineLockChecker.check(operationResult);
Mockito.verify(operationResult).conflict("Pipeline blahPipeline cannot be scheduled", "Pipeline blahPipeline is locked as another instance of this pipeline is running.", healthStateType);
when(pipelineLockService.isLocked("blahPipeline")).thenReturn(false);
pipelineLockChecker.check(operationResult);
Mockito.verify(operationResult).success(healthStateType);
}
use of com.thoughtworks.go.serverhealth.HealthStateType in project gocd by gocd.
the class AutoSchedulerIntegrationTest method shouldLogErrorIntoServerHealthServiceWhenArtifactsDiskSpaceIsFull.
@Test
public void shouldLogErrorIntoServerHealthServiceWhenArtifactsDiskSpaceIsFull() throws Exception {
serverHealthService.removeAllLogs();
ArtifactsDiskIsFull full = new ArtifactsDiskIsFull();
full.onSetUp();
if (!configService.artifactsDir().exists()) {
configService.artifactsDir().createNewFile();
}
try {
pipelineScheduler.onTimer();
HealthStateType healthStateType = HealthStateType.artifactsDiskFull();
assertThat(serverHealthService, containsState(healthStateType, HealthStateLevel.ERROR, "GoCD Server has run out of artifacts disk space. Scheduling has been stopped"));
} finally {
full.onTearDown();
configService.artifactsDir().delete();
}
}
Aggregations