use of com.thoughtworks.go.domain.PipelinePauseInfo in project gocd by gocd.
the class PipelineSchedulerIntegrationTest method shouldPauseAndUnpausePipeline_identifiedByCaseInsensitiveString.
@Test
public void shouldPauseAndUnpausePipeline_identifiedByCaseInsensitiveString() throws Exception {
configHelper.setOperatePermissionForGroup("defaultGroup", "pausedBy");
configHelper.addPipeline(PIPELINE_NAME, "stage-name");
Username userName = new Username(new CaseInsensitiveString("pauseBy"));
pipelinePauseService.pause(PIPELINE_NAME, "pauseCause", userName);
PipelinePauseInfo pauseInfo = pipelinePauseService.pipelinePauseInfo(PIPELINE_NAME);
assertThat(pauseInfo.isPaused(), is(true));
assertThat(pauseInfo.getPauseCause(), is("pauseCause"));
assertThat(pauseInfo.getPauseBy(), is("pauseBy"));
pipelinePauseService.unpause(PIPELINE_NAME);
pauseInfo = pipelinePauseService.pipelinePauseInfo(PIPELINE_NAME);
assertThat(pauseInfo.isPaused(), is(false));
}
use of com.thoughtworks.go.domain.PipelinePauseInfo in project gocd by gocd.
the class PipelineHistoryService method latestPipelineModel.
public PipelineModel latestPipelineModel(Username username, String pipelineName) {
PipelineInstanceModel instanceModel = latest(pipelineName, username);
if (instanceModel != null) {
boolean canForce = schedulingCheckerService.canManuallyTrigger(pipelineName, username);
PipelinePauseInfo pauseInfo = pipelinePauseService.pipelinePauseInfo(pipelineName);
PipelineModel pipelineModel = new PipelineModel(pipelineName, canForce, securityService.hasOperatePermissionForPipeline(username.getUsername(), pipelineName), pauseInfo);
populateLockStatus(instanceModel.getName(), username, instanceModel);
pipelineModel.addPipelineInstance(instanceModel);
String groupName = goConfigService.findGroupNameByPipeline(new CaseInsensitiveString(pipelineName));
if (goConfigService.isPipelineEditableViaUI(pipelineName))
pipelineModel.updateAdministrability(goConfigService.isUserAdminOfGroup(username.getUsername(), groupName));
else
pipelineModel.updateAdministrability(false);
return pipelineModel;
}
return null;
}
use of com.thoughtworks.go.domain.PipelinePauseInfo in project gocd by gocd.
the class PipelineHistoryService method getPipelineStatus.
public PipelineStatusModel getPipelineStatus(String pipelineName, String username, OperationResult result) {
PipelineConfig pipelineConfig = goConfigService.currentCruiseConfig().getPipelineConfigByName(new CaseInsensitiveString(pipelineName));
if (pipelineConfig == null) {
result.notFound("Not Found", "Pipeline not found", HealthStateType.general(HealthStateScope.GLOBAL));
return null;
}
if (!securityService.hasViewPermissionForPipeline(Username.valueOf(username), pipelineName)) {
result.unauthorized("Unauthorized", NOT_AUTHORIZED_TO_VIEW_PIPELINE, HealthStateType.general(HealthStateScope.forPipeline(pipelineName)));
return null;
}
PipelinePauseInfo pipelinePauseInfo = pipelinePauseService.pipelinePauseInfo(pipelineName);
boolean isCurrentlyLocked = pipelineLockService.isLocked(pipelineName);
boolean isSchedulable = schedulingCheckerService.canManuallyTrigger(pipelineConfig, username, new ServerHealthStateOperationResult());
return new PipelineStatusModel(isCurrentlyLocked, isSchedulable, pipelinePauseInfo);
}
use of com.thoughtworks.go.domain.PipelinePauseInfo in project gocd by gocd.
the class ViewCacheKeyTest method shouldGenerateKeyForPipelineModelViewFragmentWithoutSpecialCharactersInPauseCause.
@Test
public void shouldGenerateKeyForPipelineModelViewFragmentWithoutSpecialCharactersInPauseCause() {
PipelinePauseInfo pauseInfo = new PipelinePauseInfo(true, "pause& @Cause #with $special %char &*(){';/.,<>?", "admin");
PipelineModel model = new PipelineModel("pipelineName", true, true, pauseInfo).updateAdministrability(true);
StageInstanceModels stages = new StageInstanceModels();
stages.add(stageInstance("stageName", 13, JobState.Building, JobResult.Unknown));
stages.add(new NullStageHistoryItem("stage2", true));
PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createExternal(), stages);
pipelineInstance.setId(12);
model.addPipelineInstance(pipelineInstance);
StageInstanceModels stages2 = new StageInstanceModels();
stages2.add(stageInstance("stageName", 7, JobState.Completed, JobResult.Passed));
stages2.add(stageInstance("stage2", 10, JobState.Assigned, JobResult.Unknown));
PipelineInstanceModel pipelineInstance2 = PipelineInstanceModel.createPipeline("pipelineName", 7, "label-7", BuildCause.createExternal(), stages2);
pipelineInstance2.setId(14);
model.addPipelineInstance(pipelineInstance2);
assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|][14|stageName|7|Passed|stage2|10|Building|]true|true|true|pauseCausewithspecialchar|admin|true"));
}
Aggregations