Пример #1
0
 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);
 }
Пример #2
0
 public void addEnvironments(String... environmentNames) {
   CruiseConfig config = loadForEdit();
   for (String environmentName : environmentNames) {
     config.addEnvironment(environmentName);
   }
   writeConfigFile(config);
 }
Пример #3
0
 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;
 }
Пример #4
0
 public void setPipelineLabelTemplate(String pipelineName, String labelTemplate) {
   CruiseConfig config = loadForEdit();
   config
       .pipelineConfigByName(new CaseInsensitiveString(pipelineName))
       .setLabelTemplate(labelTemplate);
   writeConfigFile(config);
 }
Пример #5
0
 public void addMingleConfigToPipeline(String pipelineName, MingleConfig mingleConfig) {
   CruiseConfig config = loadForEdit();
   PipelineConfig pipelineConfig =
       config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   pipelineConfig.setMingleConfig(mingleConfig);
   writeConfigFile(config);
 }
Пример #6
0
 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);
 }
Пример #7
0
 public void requireApproval(String pipelineName, String stageName) {
   CruiseConfig cruiseConfig = loadForEdit();
   cruiseConfig
       .pipelineConfigByName(new CaseInsensitiveString(pipelineName))
       .findBy(new CaseInsensitiveString(stageName))
       .updateApproval(Approval.manualApproval());
   writeConfigFile(cruiseConfig);
 }
Пример #8
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);
 }
Пример #9
0
  public void setBaseUrls(ServerSiteUrlConfig siteUrl, ServerSiteUrlConfig secureSiteUrl) {
    CruiseConfig config = loadForEdit();

    config.setServerConfig(
        new ServerConfig(
            config.server().security(), config.server().mailHost(), siteUrl, secureSiteUrl));
    writeConfigFile(config);
  }
Пример #10
0
 public void removePipeline(String pipelineName) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfigs groups = removePipeline(pipelineName, cruiseConfig);
   if (groups.isEmpty()) {
     cruiseConfig.getGroups().remove(groups);
   }
   writeConfigFile(cruiseConfig);
 }
Пример #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;
 }
Пример #12
0
 public void addEnvironmentVariableToPipeline(
     String pipelineName, EnvironmentVariablesConfig envVars) {
   CruiseConfig cruiseConfig = loadForEdit();
   PipelineConfig pipelineConfig =
       cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
   pipelineConfig.setVariables(envVars);
   writeConfigFile(cruiseConfig);
 }
Пример #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;
 }
Пример #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);
 }
Пример #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;
 }
Пример #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;
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
 }
Пример #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;
 }
Пример #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;
 }
Пример #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);
 }
Пример #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);
 }
Пример #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;
  }
Пример #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);
 }
Пример #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);
 }
Пример #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;
 }
Пример #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);
 }
Пример #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;
 }
Пример #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;
 }