public CaseInsensitiveString findEnvironmentNameForPipeline(final CaseInsensitiveString pipelineName) { EnvironmentConfig environment = findEnvironmentForPipeline(pipelineName); return environment == null ? null : environment.name(); }
public EnvironmentVariableContext environmentVariableContextFor(String pipelineName) { EnvironmentConfig environment = environments.findEnvironmentForPipeline(new CaseInsensitiveString(pipelineName)); if (environment != null) { return environment.createEnvironmentContext(); } return null; }
private List<EnvironmentPipelineModel> getAllPipelinesForUser(Username user, List<PipelineConfig> pipelineConfigs) { List<EnvironmentPipelineModel> pipelines = new ArrayList<>(); for (PipelineConfig pipelineConfig : pipelineConfigs) { String pipelineName = CaseInsensitiveString.str(pipelineConfig.name()); if (securityService.hasViewPermissionForPipeline(user, pipelineName)) { EnvironmentConfig environment = environments.findEnvironmentForPipeline(new CaseInsensitiveString(pipelineName)); if (environment != null) { pipelines.add(new EnvironmentPipelineModel(pipelineName, CaseInsensitiveString.str(environment.name()))); } else { pipelines.add(new EnvironmentPipelineModel(pipelineName)); } } } Collections.sort(pipelines); return pipelines; }
@Override public boolean hasVariableInScope(String pipelineName, String variableName) { EnvironmentConfig environmentConfig = environments.findEnvironmentForPipeline(new CaseInsensitiveString(pipelineName)); if (environmentConfig != null) { if (environmentConfig.hasVariable(variableName)) { return true; } } return pipelineConfigByName(new CaseInsensitiveString(pipelineName)).hasVariableInScope(variableName); }
@Test public void shouldFindEnvironmentGivenPipelineName() throws Exception { assertThat(configs.findEnvironmentForPipeline(new CaseInsensitiveString("deployment")), is(env)); }
@Override public EnvironmentVariablesConfig variablesFor(String pipelineName) { EnvironmentVariablesConfig pipelineVariables = pipelineConfigByName(new CaseInsensitiveString(pipelineName)).getVariables(); EnvironmentConfig environment = this.environments.findEnvironmentForPipeline(new CaseInsensitiveString(pipelineName)); return environment != null ? environment.getVariables().overrideWith(pipelineVariables) : pipelineVariables; }
public Agents agentsForPipeline(final CaseInsensitiveString pipelineName) { Agents configs = new Agents(); if (environments.isPipelineAssociatedWithAnyEnvironment(pipelineName)) { EnvironmentConfig forPipeline = environments.findEnvironmentForPipeline(pipelineName); for (EnvironmentAgentConfig environmentAgentConfig : forPipeline.getAgents()) { configs.add(goConfigService.agentByUuid(environmentAgentConfig.getUuid())); } } else { for (AgentConfig agentConfig : goConfigService.agents()) { if (!environments.isAgentUnderEnvironment(agentConfig.getUuid())) { configs.add(agentConfig); } } } return configs; }