Search in sources :

Example 1 with PipelineGroups

use of com.thoughtworks.go.domain.PipelineGroups 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 2 with PipelineGroups

use of com.thoughtworks.go.domain.PipelineGroups in project gocd by gocd.

the class PipelineConfigServiceTest method shouldGetAllViewablePipelineConfigs.

@Test
public void shouldGetAllViewablePipelineConfigs() throws Exception {
    CruiseConfig cruiseConfig = mock(BasicCruiseConfig.class);
    PipelineConfig p1 = PipelineConfigMother.pipelineConfig("P1");
    PipelineConfig p2 = PipelineConfigMother.pipelineConfig("P2");
    Username username = new Username(new CaseInsensitiveString("user"));
    when(goConfigService.cruiseConfig()).thenReturn(cruiseConfig);
    when(cruiseConfig.getGroups()).thenReturn(new PipelineGroups(new BasicPipelineConfigs("group1", null, p1), new BasicPipelineConfigs("group2", null, p2)));
    when(securityService.hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), "group1")).thenReturn(true);
    when(securityService.hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), "group2")).thenReturn(false);
    List<PipelineConfigs> pipelineConfigs = pipelineConfigService.viewableOrOperatableGroupsFor(username);
    assertThat(pipelineConfigs.size(), is(1));
    assertThat(pipelineConfigs.get(0).getGroup(), is("group1"));
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.Test)

Example 3 with PipelineGroups

use of com.thoughtworks.go.domain.PipelineGroups in project gocd by gocd.

the class PipelineConfigServiceTest method shouldGetAllViewableOrOperatablePipelineConfigs.

@Test
public void shouldGetAllViewableOrOperatablePipelineConfigs() throws Exception {
    CruiseConfig cruiseConfig = mock(BasicCruiseConfig.class);
    PipelineConfig p1 = PipelineConfigMother.pipelineConfig("P1");
    PipelineConfig p2 = PipelineConfigMother.pipelineConfig("P2");
    PipelineConfig p3 = PipelineConfigMother.pipelineConfig("P3");
    Username username = new Username(new CaseInsensitiveString("user"));
    when(goConfigService.cruiseConfig()).thenReturn(cruiseConfig);
    when(cruiseConfig.getGroups()).thenReturn(new PipelineGroups(new BasicPipelineConfigs("group1", null, p1), new BasicPipelineConfigs("group2", null, p2), new BasicPipelineConfigs("group3", null, p3)));
    when(securityService.hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), "group1")).thenReturn(true);
    when(securityService.hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), "group2")).thenReturn(false);
    when(securityService.hasOperatePermissionForGroup(username.getUsername(), "group2")).thenReturn(false);
    when(securityService.hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), "group3")).thenReturn(false);
    when(securityService.hasOperatePermissionForGroup(username.getUsername(), "group3")).thenReturn(true);
    List<PipelineConfigs> pipelineConfigs = pipelineConfigService.viewableOrOperatableGroupsFor(username);
    assertThat(pipelineConfigs.size(), is(2));
    assertThat(pipelineConfigs.get(0).getGroup(), is("group1"));
    assertThat(pipelineConfigs.get(1).getGroup(), is("group3"));
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.Test)

Example 4 with PipelineGroups

use of com.thoughtworks.go.domain.PipelineGroups in project gocd by gocd.

the class PartialConfigMother method withPipeline.

public static PartialConfig withPipeline(String name, RepoConfigOrigin repoOrigin) {
    PipelineConfig pipe = PipelineConfigMother.pipelineConfig(name);
    BasicPipelineConfigs pipes = new BasicPipelineConfigs(pipe);
    pipes.setGroup("group");
    PartialConfig partialConfig = new PartialConfig(new PipelineGroups(pipes));
    partialConfig.setOrigins(repoOrigin);
    return partialConfig;
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig)

Example 5 with PipelineGroups

use of com.thoughtworks.go.domain.PipelineGroups in project gocd by gocd.

the class PartialConfigMother method withPipelineInGroup.

public static PartialConfig withPipelineInGroup(String pipelineName, String groupName) {
    PipelineConfig pipe = PipelineConfigMother.pipelineConfig(pipelineName);
    BasicPipelineConfigs pipes = new BasicPipelineConfigs(groupName, new Authorization(), pipe);
    PartialConfig partialConfig = new PartialConfig(new PipelineGroups(pipes));
    partialConfig.setOrigins(createRepoOrigin());
    return partialConfig;
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig)

Aggregations

PipelineGroups (com.thoughtworks.go.domain.PipelineGroups)12 Test (org.junit.Test)7 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)4 Username (com.thoughtworks.go.server.domain.Username)2 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)1 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)1 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)1 CaseInsensitiveStringTest (com.thoughtworks.go.domain.CaseInsensitiveStringTest)1 PipelinePauseInfo (com.thoughtworks.go.domain.PipelinePauseInfo)1 Material (com.thoughtworks.go.domain.materials.Material)1 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)1 PostCommitHookImplementer (com.thoughtworks.go.server.materials.postcommit.PostCommitHookImplementer)1 PostCommitHookMaterialType (com.thoughtworks.go.server.materials.postcommit.PostCommitHookMaterialType)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 Before (org.junit.Before)1