@Before
  public void setup() throws Exception {
    configHelper = new GoConfigFileHelper();
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    testRepo = new SvnTestRepo("testSvnRepo");
    dbHelper.onSetUp();
    repository = new SvnCommand(null, testRepo.projectRepositoryUrl());
    mingleConfig = configHelper.addPipeline("mingle", STAGE_NAME, repository, "unit", "functional");

    goConfig = configHelper.addPipeline("go", STAGE_NAME, repository, "unit");
    StageConfig ftStageConfig = StageConfigMother.custom("ft", "twist");
    ftStageConfig
        .jobConfigByConfigName(new CaseInsensitiveString("twist"))
        .addVariable("JOB_LVL", "job value");
    ftStageConfig.setVariables(env("STAGE_LVL", "stage value"));
    configHelper.addStageToPipeline("go", ftStageConfig);
    configHelper.addEnvironmentVariableToPipeline("go", env("PIPELINE_LVL", "pipeline value"));
    configHelper.addEnvironments("uat");
    EnvironmentConfig uatEnv =
        configHelper.currentConfig().getEnvironments().named(new CaseInsensitiveString("uat"));
    uatEnv.addPipeline(new CaseInsensitiveString("go"));
    uatEnv.addEnvironmentVariable("ENV_LVL", "env value");

    evolveConfig = configHelper.addPipeline("evolve", STAGE_NAME, repository, "unit");
    goCache.clear();
  }
Example #2
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;
 }
 @Before
 public void setUp() throws Exception {
   pipelineConfig =
       PipelineConfigMother.pipelineConfig(
           "mingle",
           StageConfigMother.custom("dev", "defaultJob"),
           StageConfigMother.manualStage("ft"));
   pipelinePauseInfo = PipelinePauseInfo.notPaused();
   presenter =
       new PipelineHistoryJsonPresentationModel(
           pipelinePauseInfo,
           preparePipelineHistoryGroups(pipelineConfig),
           pipelineConfig,
           pagination(),
           CAN_FORCE,
           hasForceBuildCause,
           hasModification,
           true);
 }
  @Test
  public void shouldReturnJsonForNullStage() throws Exception {
    final StageConfig config = StageConfigMother.oneBuildPlanWithResourcesAndMaterials("newStage");
    StageJsonPresentationModel presenter =
        new StageJsonPresentationModel(
            pipeline, NullStage.createNullStage(config), null, new Agents());
    Map json = presenter.toJson();

    new JsonTester((List) json.get("builds")).shouldContain("[{ 'current_status' : 'unknown' }]");
  }
Example #5
0
 private PipelineConfig configurePipeline(
     String pipelineName, String stageName, String... jobConfigNames) {
   final String[] defaultBuildPlanNames = {"functional", "unit"};
   jobConfigNames = jobConfigNames.length == 0 ? defaultBuildPlanNames : jobConfigNames;
   StageConfig stageConfig =
       StageConfigMother.stageConfig(stageName, BuildPlanMother.withBuildPlans(jobConfigNames));
   MaterialConfigs materialConfigs = MaterialConfigsMother.multipleMaterialConfigs();
   PipelineConfig pipelineConfig =
       new PipelineConfig(new CaseInsensitiveString(pipelineName), materialConfigs, stageConfig);
   return pipelineConfig;
 }
 @Before
 public void setup() {
   initMocks(this);
   currentUser = new Username(new CaseInsensitiveString("user"));
   cruiseConfig = new GoConfigMother().defaultCruiseConfig();
   pipelineTemplateConfig =
       new PipelineTemplateConfig(
           new CaseInsensitiveString("template"),
           StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
   result = new HttpLocalizedOperationResult();
 }
Example #7
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;
 }
Example #8
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;
  }