Exemple #1
0
 GoAcl readAclBy(String pipelineName, String stageName) {
   PipelineConfig pipelineConfig = pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
   StageConfig stageConfig = pipelineConfig.findBy(new CaseInsensitiveString(stageName));
   AdminsConfig adminsConfig = stageConfig.getApproval().getAuthConfig();
   List<CaseInsensitiveString> users = getAuthorizedUsers(adminsConfig);
   return new GoAcl(users);
 }
Exemple #2
0
 public List<CaseInsensitiveString> pipelines(String group) {
   PipelineConfigs configs = getCurrentConfig().pipelines(group);
   List<CaseInsensitiveString> pipelines = new ArrayList<>();
   for (PipelineConfig config : configs) {
     pipelines.add(config.name());
   }
   return pipelines;
 }
Exemple #3
0
 public List<PipelineConfig> downstreamPipelinesOf(String pipelineName) {
   List<PipelineConfig> dependencies = new ArrayList<>();
   for (PipelineConfig config : getAllPipelineConfigs()) {
     if (config.dependsOn(new CaseInsensitiveString(pipelineName))) {
       dependencies.add(config);
     }
   }
   return dependencies;
 }
Exemple #4
0
 private List<String> invertSelections(List<String> selectedPipelines) {
   List<String> unselectedPipelines = new ArrayList<>();
   List<PipelineConfig> pipelineConfigList = cruiseConfig().getAllPipelineConfigs();
   for (PipelineConfig pipelineConfig : pipelineConfigList) {
     String pipelineName = CaseInsensitiveString.str(pipelineConfig.name());
     if (!selectedPipelines.contains(pipelineName)) {
       unselectedPipelines.add(pipelineName);
     }
   }
   return unselectedPipelines;
 }
Exemple #5
0
 private PipelineConfigDependencyGraph findUpstream(PipelineConfig currentPipeline) {
   List<PipelineConfigDependencyGraph> graphs = new ArrayList<>();
   for (CaseInsensitiveString name : currentPipeline.upstreamPipelines()) {
     PipelineConfig pipelineConfig = getCurrentConfig().pipelineConfigByName(name);
     graphs.add(findUpstream(pipelineConfig));
   }
   return new PipelineConfigDependencyGraph(
       currentPipeline, graphs.toArray(new PipelineConfigDependencyGraph[0]));
 }
Exemple #6
0
 public JobConfigIdentifier translateToActualCase(JobConfigIdentifier identifier) {
   PipelineConfig pipelineConfig =
       getCurrentConfig()
           .pipelineConfigByName(new CaseInsensitiveString(identifier.getPipelineName()));
   String translatedPipelineName = CaseInsensitiveString.str(pipelineConfig.name());
   StageConfig stageConfig =
       pipelineConfig.findBy(new CaseInsensitiveString(identifier.getStageName()));
   if (stageConfig == null) {
     throw new StageNotFoundException(
         new CaseInsensitiveString(identifier.getPipelineName()),
         new CaseInsensitiveString(identifier.getStageName()));
   }
   String translatedStageName = CaseInsensitiveString.str(stageConfig.name());
   JobConfig plan = stageConfig.jobConfigByInstanceName(identifier.getJobName(), true);
   if (plan == null) {
     throw new JobNotFoundException(
         identifier.getPipelineName(), identifier.getStageName(), identifier.getJobName());
   }
   String translatedJobName = plan.translatedName(identifier.getJobName());
   return new JobConfigIdentifier(translatedPipelineName, translatedStageName, translatedJobName);
 }
Exemple #7
0
  public PipelineConfig toPipelineConfig(CRPipeline crPipeline) {
    MaterialConfigs materialConfigs = new MaterialConfigs();
    for (CRMaterial crMaterial : crPipeline.getMaterials()) {
      materialConfigs.add(toMaterialConfig(crMaterial));
    }

    PipelineConfig pipelineConfig =
        new PipelineConfig(new CaseInsensitiveString(crPipeline.getName()), materialConfigs);

    for (CRStage crStage : crPipeline.getStages()) {
      pipelineConfig.add(toStage(crStage));
    }

    if (crPipeline.getLabelTemplate() != null)
      pipelineConfig.setLabelTemplate(crPipeline.getLabelTemplate());

    CRTrackingTool crTrackingTool = crPipeline.getTrackingTool();
    if (crTrackingTool != null) {
      pipelineConfig.setTrackingTool(toTrackingTool(crTrackingTool));
    }
    CRMingle crMingle = crPipeline.getMingle();
    if (crMingle != null) {
      pipelineConfig.setMingleConfig(toMingleConfig(crMingle));
    }

    CRTimer crTimer = crPipeline.getTimer();
    if (crTimer != null) {
      pipelineConfig.setTimer(toTimerConfig(crTimer));
    }

    EnvironmentVariablesConfig variables = pipelineConfig.getVariables();
    for (CREnvironmentVariable crEnvironmentVariable : crPipeline.getEnvironmentVariables()) {
      variables.add(toEnvironmentVariableConfig(crEnvironmentVariable));
    }

    pipelineConfig.setLock(crPipeline.isLocked());

    return pipelineConfig;
  }
Exemple #8
0
 public boolean isPipelineEditableViaUI(String pipelineName) {
   PipelineConfig pipelineConfig =
       this.pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
   if (pipelineConfig == null) return false;
   return isOriginLocal(pipelineConfig.getOrigin());
 }