Ejemplo n.º 1
0
 private void updateApproval(String pipelineName, String ftStage, Approval manualApproval) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   StageConfig config = pipelineConfig.findBy(new CaseInsensitiveString(ftStage));
   config.updateApproval(manualApproval);
   writeConfigFile(cruiseConfig);
 }
Ejemplo n.º 2
0
 public void addEnvironmentVariableToStage(
     String pipelineName, String stageName, EnvironmentVariablesConfig envVars) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   StageConfig stageConfig = pipelineConfig.findBy(new CaseInsensitiveString(stageName));
   stageConfig.setVariables(envVars);
   writeConfigFile(cruiseConfig);
 }
Ejemplo n.º 3
0
 public void removeJob(String pipelineName, String stageName, String jobName) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   StageConfig stageConfig = pipelineConfig.findBy(new CaseInsensitiveString(stageName));
   JobConfig job = stageConfig.getJobs().getJob(new CaseInsensitiveString(jobName));
   stageConfig.getJobs().remove(job);
   writeConfigFile(cruiseConfig);
 }
Ejemplo n.º 4
0
 public void setOperatePermissionForStage(String pipelineName, String stageName, String username) {
   CruiseConfig cruiseConfig = loadForEdit();
   StageConfig stageConfig =
       cruiseConfig
           .pipelineConfigByName(new CaseInsensitiveString(pipelineName))
           .findBy(new CaseInsensitiveString(stageName));
   stageConfig.updateApproval(
       new Approval(new AuthConfig(new AdminUser(new CaseInsensitiveString(username)))));
   writeConfigFile(cruiseConfig);
 }
Ejemplo n.º 5
0
 public void addAuthorizedUserForStage(String pipelineName, String stageName, String... users) {
   configureStageAsManualApproval(pipelineName, stageName);
   CruiseConfig cruiseConfig = loadForEdit();
   StageConfig stageConfig =
       cruiseConfig.stageConfigByName(
           new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(stageName));
   Approval approval = stageConfig.getApproval();
   for (String user : users) {
     approval.getAuthConfig().add(new AdminUser(new CaseInsensitiveString(user)));
   }
   writeConfigFile(cruiseConfig);
 }
Ejemplo n.º 6
0
 private StageConfig pushJobIntoStage(
     String pipelineName, String stageName, JobConfig jobConfig, boolean clearExistingJobs) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   StageConfig stageConfig = pipelineConfig.findBy(new CaseInsensitiveString(stageName));
   if (clearExistingJobs) {
     stageConfig.allBuildPlans().clear();
   }
   stageConfig.allBuildPlans().add(jobConfig);
   writeConfigFile(cruiseConfig);
   return stageConfig;
 }
Ejemplo n.º 7
0
  public PipelineConfig changeStagenameForToPipeline(
      String pipelineName, String oldStageName, String newStageName) {
    CruiseConfig config = loadForEdit();
    PipelineConfig pipelineConfig =
        config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));

    StageConfig stage = pipelineConfig.getStage(new CaseInsensitiveString(oldStageName));
    int index = pipelineConfig.indexOf(stage);

    stage =
        StageConfigMother.custom(
            newStageName,
            stage.isFetchMaterials(),
            stage.isCleanWorkingDir(),
            stage.getJobs(),
            stage.getApproval());
    pipelineConfig.set(index, stage);

    writeConfigFile(config);
    return pipelineConfig;
  }