use of com.thoughtworks.go.domain.PipelinePauseInfo in project gocd by gocd.
the class PipelineHistoryController method list.
@RequestMapping(value = "/**/pipelineHistory.json", method = RequestMethod.GET)
public ModelAndView list(@RequestParam("pipelineName") String pipelineName, @RequestParam(value = "perPage", required = false) Integer perPageParam, @RequestParam(value = "start", required = false) Integer startParam, @RequestParam(value = "labelFilter", required = false) String labelFilter, HttpServletResponse response, HttpServletRequest request) throws NamingException {
PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
String username = CaseInsensitiveString.str(UserHelper.getUserName().getUsername());
Pagination pagination;
try {
pagination = Pagination.pageStartingAt(startParam, pipelineHistoryService.totalCount(pipelineName), perPageParam);
} catch (Exception e) {
Map<String, Object> json = new LinkedHashMap<>();
addDeveloperErrorMessage(json, e);
return jsonNotAcceptable(json).respond(response);
}
PipelinePauseInfo pauseInfo = pipelinePauseService.pipelinePauseInfo(pipelineName);
boolean hasBuildCauseInBuffer = pipelineScheduleQueue.hasBuildCause(CaseInsensitiveString.str(pipelineConfig.name()));
PipelineInstanceModels pipelineHistory = StringUtil.isBlank(labelFilter) ? pipelineHistoryService.load(pipelineName, pagination, username, true) : pipelineHistoryService.findMatchingPipelineInstances(pipelineName, labelFilter, perPageParam, UserHelper.getUserName(), new HttpLocalizedOperationResult());
boolean hasForcedBuildCause = pipelineScheduleQueue.hasForcedBuildCause(pipelineName);
PipelineHistoryJsonPresentationModel historyJsonPresenter = new PipelineHistoryJsonPresentationModel(pauseInfo, pipelineHistory, pipelineConfig, pagination, canForce(pipelineConfig, username), hasForcedBuildCause, hasBuildCauseInBuffer, canPause(pipelineConfig, username));
return jsonFound(historyJsonPresenter.toJson()).respond(response);
}
use of com.thoughtworks.go.domain.PipelinePauseInfo in project gocd by gocd.
the class PipelineHistoryService method allPipelineInstances.
private PipelineGroupModels allPipelineInstances(Username username) {
CruiseConfig currentConfig = goConfigService.currentCruiseConfig();
PipelineGroups groups = currentConfig.getGroups();
PipelineInstanceModels activePipelines = filterPermissions(pipelineDao.loadActivePipelines(), username);
PipelineGroupModels groupModels = new PipelineGroupModels();
for (PipelineConfig pipelineConfig : currentConfig.getAllPipelineConfigs()) {
CaseInsensitiveString pipelineName = pipelineConfig.name();
for (PipelineInstanceModel activePipeline : activePipelines.findAll(CaseInsensitiveString.str(pipelineName))) {
activePipeline.setTrackingTool(pipelineConfig.getTrackingTool());
activePipeline.setMingleConfig(pipelineConfig.getMingleConfig());
populatePlaceHolderStages(activePipeline);
String groupName = groups.findGroupNameByPipeline(pipelineName);
if (groupName == null) {
throw new RuntimeException("Unable to find group find pipeline " + pipelineName);
}
populatePreviousStageState(activePipeline);
populateLockStatus(activePipeline.getName(), username, activePipeline);
boolean canForce = schedulingCheckerService.canManuallyTrigger(CaseInsensitiveString.str(pipelineName), username);
PipelinePauseInfo pauseInfo = pipelinePauseService.pipelinePauseInfo(CaseInsensitiveString.str(pipelineName));
groupModels.addPipelineInstance(groupName, activePipeline, canForce, securityService.hasOperatePermissionForPipeline(username.getUsername(), CaseInsensitiveString.str(pipelineName)), pauseInfo);
}
}
for (PipelineConfigs group : groups) {
populateMissingPipelines(username, groupModels, group);
}
return groupModels;
}
use of com.thoughtworks.go.domain.PipelinePauseInfo in project gocd by gocd.
the class ViewCacheKey method keyForPipelineModelFragment.
private String keyForPipelineModelFragment(PipelineModel model, String name) {
StringBuilder s = new StringBuilder();
s.append(name);
//FIXME: use the delimiter, the two values appended at this point can combine to get something completely different (ALWAYS USE DELIMITER.)!!! - Sara & JJ
s.append(model.getName());
appendLockStatus(model, s);
for (PipelineInstanceModel pim : model.getActivePipelineInstances()) {
s.append("[");
s.append(pim.getId()).append(DELIMITER);
for (StageInstanceModel stageInstanceModel : pim.getStageHistory()) {
s.append(stageInstanceModel.getName()).append(DELIMITER);
s.append(stageInstanceModel.getId()).append(DELIMITER);
s.append(stageInstanceModel.getState()).append(DELIMITER);
}
s.append("]");
}
s.append(model.canOperate()).append(DELIMITER);
s.append(model.canForce()).append(DELIMITER);
PipelinePauseInfo pauseInfo = model.getPausedInfo();
s.append(pauseInfo.isPaused()).append(DELIMITER).append(pauseInfo.getPauseCause().replaceAll("\\W", "")).append(DELIMITER).append(pauseInfo.getPauseBy());
s.append(DELIMITER).append(model.canAdminister());
return key(s.toString());
}
use of com.thoughtworks.go.domain.PipelinePauseInfo in project gocd by gocd.
the class CachedCurrentActivityService method pipelineModel.
private PipelineJsonPresentationModel pipelineModel(PipelineConfig pipelineConfig) {
String name = CaseInsensitiveString.str(pipelineConfig.name());
PipelinePauseInfo pauseInfo = pipelinePauseService.pipelinePauseInfo(name);
boolean forcedBuild = pipelineScheduleQueue.hasForcedBuildCause(name);
List<StageJsonPresentationModel> stageModels = stagesModel(pipelineConfig);
return new PipelineJsonPresentationModel(goConfigService.findGroupNameByPipeline(new CaseInsensitiveString(name)), name, pauseInfo, forcedBuild, stageModels);
}
use of com.thoughtworks.go.domain.PipelinePauseInfo in project gocd by gocd.
the class PipelineSchedulerIntegrationTest method shouldPauseAndUnpausePipeline.
@Test
public void shouldPauseAndUnpausePipeline() 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));
}
Aggregations