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 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; }
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 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); }
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); }
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 void addResourcesFor( String pipelineName, String stageName, String jobName, String... resources) { CruiseConfig config = loadForEdit(); PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString(pipelineName)); for (String resource : resources) { pipelineConfig .findBy(new CaseInsensitiveString(stageName)) .jobConfigByConfigName(new CaseInsensitiveString(jobName)) .addResource(resource); } writeConfigFile(config); }