Search in sources :

Example 6 with PipelinePauseInfo

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

Example 7 with PipelinePauseInfo

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

Example 8 with PipelinePauseInfo

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);
}
Also used : PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) PipelineStatusModel(com.thoughtworks.go.presentation.PipelineStatusModel)

Example 9 with 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"));
}
Also used : NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) 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