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 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); }
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); }
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); }
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); }
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; }
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; }