public void addParamToPipeline(String pipeline, String paramName, String paramValue) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipeline));
   pipelineConfig.addParam(new ParamConfig(paramName, paramValue));
   writeConfigFile(cruiseConfig);
 }
 public void addEnvironments(String... environmentNames) {
   CruiseConfig config = loadForEdit();
   for (String environmentName : environmentNames) {
     config.addEnvironment(environmentName);
   }
   writeConfigFile(config);
 }
 public PipelineConfigs removePipeline(String pipelineName, CruiseConfig cruiseConfig) {
   String groupName =
       cruiseConfig.getGroups().findGroupNameByPipeline(new CaseInsensitiveString(pipelineName));
   PipelineConfigs groups = cruiseConfig.getGroups().findGroup(groupName);
   groups.remove(cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName)));
   return groups;
 }
 public void setPipelineLabelTemplate(String pipelineName, String labelTemplate) {
   CruiseConfig config = loadForEdit();
   config
       .pipelineConfigByName(new CaseInsensitiveString(pipelineName))
       .setLabelTemplate(labelTemplate);
   writeConfigFile(config);
 }
 public void addMingleConfigToPipeline(String pipelineName, MingleConfig mingleConfig) {
   CruiseConfig config = loadForEdit();
   PipelineConfig pipelineConfig =
       config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   pipelineConfig.setMingleConfig(mingleConfig);
   writeConfigFile(config);
 }
 public void addAdminRoles(String... roleNames) {
   CruiseConfig cruiseConfig = loadForEdit();
   AdminsConfig adminsConfig = cruiseConfig.server().security().adminsConfig();
   for (String roleName : roleNames) {
     adminsConfig.add(new AdminRole(new CaseInsensitiveString(roleName)));
   }
   writeConfigFile(cruiseConfig);
 }
 public void requireApproval(String pipelineName, String stageName) {
   CruiseConfig cruiseConfig = loadForEdit();
   cruiseConfig
       .pipelineConfigByName(new CaseInsensitiveString(pipelineName))
       .findBy(new CaseInsensitiveString(stageName))
       .updateApproval(Approval.manualApproval());
   writeConfigFile(cruiseConfig);
 }
 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);
 }
  public void setBaseUrls(ServerSiteUrlConfig siteUrl, ServerSiteUrlConfig secureSiteUrl) {
    CruiseConfig config = loadForEdit();

    config.setServerConfig(
        new ServerConfig(
            config.server().security(), config.server().mailHost(), siteUrl, secureSiteUrl));
    writeConfigFile(config);
  }
Beispiel #10
0
 public void removePipeline(String pipelineName) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfigs groups = removePipeline(pipelineName, cruiseConfig);
   if (groups.isEmpty()) {
     cruiseConfig.getGroups().remove(groups);
   }
   writeConfigFile(cruiseConfig);
 }
Beispiel #11
0
 public PipelineConfig addStageToPipeline(String pipelineName, StageConfig stageConfig) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   pipelineConfig.add(stageConfig);
   writeConfigFile(cruiseConfig);
   return pipelineConfig;
 }
Beispiel #12
0
 public void addEnvironmentVariableToPipeline(
     String pipelineName, EnvironmentVariablesConfig envVars) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   pipelineConfig.setVariables(envVars);
   writeConfigFile(cruiseConfig);
 }
Beispiel #13
0
 public PipelineConfig updatePipeline(
     CaseInsensitiveString pipelineName, Updater<PipelineConfig> updater) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig = cruiseConfig.getPipelineConfigByName(pipelineName);
   updater.update(pipelineConfig);
   writeConfigFile(cruiseConfig);
   return pipelineConfig;
 }
Beispiel #14
0
 public void setViewPermissionForGroup(String groupName, String username) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfigs group = cruiseConfig.getGroups().findGroup(groupName);
   group
       .getAuthorization()
       .getViewConfig()
       .add(new AdminUser(new CaseInsensitiveString(username)));
   writeConfigFile(cruiseConfig);
 }
Beispiel #15
0
 public StageConfig removeStage(String pipelineName, String stageName) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   StageConfig stageConfig = pipelineConfig.findBy(new CaseInsensitiveString(stageName));
   pipelineConfig.remove(stageConfig);
   writeConfigFile(cruiseConfig);
   return stageConfig;
 }
Beispiel #16
0
 public PipelineConfig removeMaterialFromPipeline(
     String pipelineName, MaterialConfig materialConfig) {
   CruiseConfig config = loadForEdit();
   PipelineConfig pipelineConfig =
       config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   pipelineConfig.removeMaterialConfig(materialConfig);
   writeConfigFile(config);
   return pipelineConfig;
 }
Beispiel #17
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);
 }
Beispiel #18
0
 public void addEnvironmentVariablesToEnvironment(
     String environmentName, String variableName, String variableValue)
     throws NoSuchEnvironmentException {
   CruiseConfig config = loadForEdit();
   EnvironmentConfig env =
       config.getEnvironments().named(new CaseInsensitiveString(environmentName));
   env.addEnvironmentVariable(variableName, variableValue);
   writeConfigFile(config);
 }
Beispiel #19
0
 public void addEnvironmentVariableToJob(
     String pipelineName, String stageName, String jobName, EnvironmentVariablesConfig envVars) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   StageConfig stageConfig = pipelineConfig.findBy(new CaseInsensitiveString(stageName));
   JobConfig jobConfig = stageConfig.jobConfigByConfigName(new CaseInsensitiveString(jobName));
   jobConfig.setVariables(envVars);
   writeConfigFile(cruiseConfig);
 }
Beispiel #20
0
 public PipelineConfig addMaterialToPipeline(String pipelineName, MaterialConfig materialConfig) {
   CruiseConfig config = loadForEdit();
   PipelineConfig pipelineConfig =
       config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   for (MaterialConfig materialConfig1 : new MaterialConfig[] {materialConfig}) {
     pipelineConfig.addMaterialConfig(materialConfig1);
   }
   writeConfigFile(config);
   return pipelineConfig;
 }
Beispiel #21
0
 public PipelineTemplateConfig addTemplate(
     String pipelineName, Authorization authorization, String stageName) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineTemplateConfig templateConfig =
       PipelineTemplateConfigMother.createTemplate(
           pipelineName, authorization, StageConfigMother.manualStage(stageName));
   cruiseConfig.getTemplates().add(templateConfig);
   writeConfigFile(cruiseConfig);
   return templateConfig;
 }
Beispiel #22
0
 public void blockPipelineGroupExceptFor(String pipelineGroupName, String roleName) {
   CruiseConfig config = loadForEdit();
   PipelineConfigs configs = config.getGroups().findGroup(pipelineGroupName);
   Authorization authorization =
       new Authorization(
           new OperationConfig(new AdminRole(new CaseInsensitiveString(roleName))),
           new ViewConfig(new AdminRole(new CaseInsensitiveString(roleName))));
   configs.setAuthorization(authorization);
   writeConfigFile(config);
 }
Beispiel #23
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);
 }
Beispiel #24
0
  private PipelineConfig replaceMaterialConfigForPipeline(
      String pipelinename, MaterialConfigs materialConfigs) {
    CruiseConfig cruiseConfig = loadForEdit();
    PipelineConfig pipelineConfig =
        cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelinename));
    pipelineConfig.setMaterialConfigs(materialConfigs);

    writeConfigFile(cruiseConfig);
    return pipelineConfig;
  }
Beispiel #25
0
 public void setRunOnAllAgents(
     String pipelineName, String stageName, String jobName, boolean runOnAllAgents) {
   CruiseConfig config = loadForEdit();
   PipelineConfig pipelineConfig =
       config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   pipelineConfig
       .findBy(new CaseInsensitiveString(stageName))
       .jobConfigByInstanceName(jobName, true)
       .setRunOnAllAgents(runOnAllAgents);
   writeConfigFile(config);
 }
Beispiel #26
0
 public void setRunMultipleInstance(
     String pipelineName, String stageName, String jobName, Integer runInstanceCount) {
   CruiseConfig config = loadForEdit();
   PipelineConfig pipelineConfig =
       config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   pipelineConfig
       .findBy(new CaseInsensitiveString(stageName))
       .jobConfigByInstanceName(jobName, true)
       .setRunInstanceCount(runInstanceCount);
   writeConfigFile(config);
 }
Beispiel #27
0
 public PipelineConfig addPipelineWithTemplate(
     String groupName, String pipelineName, String templateName) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       new PipelineConfig(
           new CaseInsensitiveString(pipelineName),
           MaterialConfigsMother.mockMaterialConfigs("svn:///user:pass@tmp/foo"));
   pipelineConfig.setTemplateName(new CaseInsensitiveString(templateName));
   cruiseConfig.findGroup(groupName).add(pipelineConfig);
   writeConfigFile(cruiseConfig);
   return pipelineConfig;
 }
Beispiel #28
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);
 }
Beispiel #29
0
 public PipelineConfig addPipelineWithInvalidMaterial(String pipelineName, String stageName) {
   CruiseConfig cruiseConfig = loadForEdit();
   StageConfig stageConfig = StageConfigMother.custom(stageName, defaultBuildPlans("buildName"));
   PipelineConfig pipelineConfig =
       new PipelineConfig(
           new CaseInsensitiveString(pipelineName),
           invalidRepositoryMaterialConfigs(),
           stageConfig);
   cruiseConfig.addPipeline(DEFAULT_GROUP, pipelineConfig);
   writeConfigFile(cruiseConfig);
   return pipelineConfig;
 }
Beispiel #30
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;
 }