Search in sources :

Example 1 with PipelinePauseInfo

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);
}
Also used : Pagination(com.thoughtworks.go.server.util.Pagination) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineHistoryJsonPresentationModel(com.thoughtworks.go.server.presentation.models.PipelineHistoryJsonPresentationModel) PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) NamingException(javax.naming.NamingException) PipelineNotFoundException(com.thoughtworks.go.config.PipelineNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PipelinePauseInfo

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;
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo)

Example 3 with PipelinePauseInfo

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());
}
Also used : PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 4 with PipelinePauseInfo

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);
}
Also used : PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo) StageJsonPresentationModel(com.thoughtworks.go.server.presentation.models.StageJsonPresentationModel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PipelineJsonPresentationModel(com.thoughtworks.go.server.presentation.models.PipelineJsonPresentationModel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 5 with PipelinePauseInfo

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));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo) Test(org.junit.Test)

Aggregations

PipelinePauseInfo (com.thoughtworks.go.domain.PipelinePauseInfo)9 Test (org.junit.Test)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)2 Username (com.thoughtworks.go.server.domain.Username)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 PipelineNotFoundException (com.thoughtworks.go.config.PipelineNotFoundException)1 PipelineGroups (com.thoughtworks.go.domain.PipelineGroups)1 PipelineStatusModel (com.thoughtworks.go.presentation.PipelineStatusModel)1 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)1 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)1 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)1 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)1 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)1 PipelineHistoryJsonPresentationModel (com.thoughtworks.go.server.presentation.models.PipelineHistoryJsonPresentationModel)1 PipelineJsonPresentationModel (com.thoughtworks.go.server.presentation.models.PipelineJsonPresentationModel)1 StageJsonPresentationModel (com.thoughtworks.go.server.presentation.models.StageJsonPresentationModel)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)1 Pagination (com.thoughtworks.go.server.util.Pagination)1