Search in sources :

Example 16 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class BuildCauseProducerServiceIntegrationTest method setup.

@Before
public void setup() throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    new HgTestRepo("testHgRepo", temporaryFolder);
    svnRepository = new SvnTestRepo(temporaryFolder);
    dbHelper.onSetUp();
    configHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    repository = new SvnCommand(null, svnRepository.projectRepositoryUrl());
    PipelineConfig goParentPipelineConfig = configHelper.addPipeline(GO_PIPELINE_UPSTREAM, STAGE_NAME, new MaterialConfigs(new GitMaterialConfig("foo-bar")), "unit");
    goPipelineConfig = configHelper.addPipeline(GO_PIPELINE_NAME, STAGE_NAME, repository, "unit");
    svnMaterialRevs = new MaterialRevisions();
    svnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
    svnMaterialRevs.addRevision(svnMaterial, svnMaterial.latestModification(null, new ServerSubprocessExecutionContext(goConfigService, new SystemEnvironment())));
    final MaterialRevisions materialRevisions = new MaterialRevisions();
    SvnMaterial anotherSvnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
    materialRevisions.addRevision(anotherSvnMaterial, anotherSvnMaterial.latestModification(null, subprocessExecutionContext));
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            materialRepository.save(svnMaterialRevs);
        }
    });
    BuildCause buildCause = BuildCause.createWithModifications(svnMaterialRevs, "");
    mingleConfig = configHelper.addPipeline(MINGLE_PIPELINE_NAME, STAGE_NAME, repository, new Filter(new IgnoredFiles("**/*.doc")), "unit", "functional");
    latestPipeline = PipelineMother.schedule(this.mingleConfig, buildCause);
    latestPipeline = pipelineDao.saveWithStages(latestPipeline);
    dbHelper.passStage(latestPipeline.getStages().first());
    pipelineScheduleQueue.clear();
    result = new HttpOperationResult();
    scheduleOptions = new ScheduleOptions();
    u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
    materialForManualTriggerPipeline = u.wf(new SvnMaterial("svn", "username", "password", false), "folder1");
    u.checkinInOrder(materialForManualTriggerPipeline, u.d(1), "s1");
    manualTriggerPipeline = configHelper.addPipeline(UUID.randomUUID().toString(), STAGE_NAME, materialForManualTriggerPipeline.config(), "build");
    username = Username.ANONYMOUS;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) TransactionStatus(org.springframework.transaction.TransactionStatus) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) Before(org.junit.Before)

Example 17 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class JobStatusListenerTest method setUp.

@Before
public void setUp() throws Exception {
    goCache.clear();
    dbHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    PipelineConfig pipelineConfig = withSingleStageWithMaterials(PIPELINE_NAME, STAGE_NAME, withBuildPlans(JOB_NAME));
    configHelper.addPipeline(PIPELINE_NAME, STAGE_NAME);
    savedPipeline = scheduleHelper.schedule(pipelineConfig, BuildCause.createWithModifications(modifyOneFile(pipelineConfig), ""), GoConstants.DEFAULT_APPROVED_BY);
    JobInstance job = savedPipeline.getStages().first().getJobInstances().first();
    job.setAgentUuid(UUID);
    mockery = new ClassMockery();
    stageStatusTopic = mockery.mock(StageStatusTopic.class);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) JobInstance(com.thoughtworks.go.domain.JobInstance) ClassMockery(com.thoughtworks.go.util.ClassMockery) Before(org.junit.Before)

Example 18 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class ParamConfigTest method shouldValidateName.

@Test
public void shouldValidateName() {
    ParamConfig paramConfig = new ParamConfig();
    ValidationContext validationContext = mock(ValidationContext.class);
    when(validationContext.getPipeline()).thenReturn(new PipelineConfig(new CaseInsensitiveString("p"), null));
    paramConfig.validateName(new HashMap<>(), validationContext);
    assertThat(paramConfig.errors().on(ParamConfig.NAME), is("Parameter cannot have an empty name for pipeline 'p'."));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) ParamConfig(com.thoughtworks.go.config.ParamConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) ValidationContext(com.thoughtworks.go.config.ValidationContext) Test(org.junit.Test)

Example 19 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class DeletePipelineConfigCommand method isValid.

@Override
public boolean isValid(CruiseConfig preprocessedConfig) {
    for (PipelineConfig pipeline : preprocessedConfig.getAllPipelineConfigs()) {
        if (pipeline.materialConfigs().hasDependencyMaterial(pipelineConfig)) {
            Localizable.CurryableLocalizable message = LocalizedMessage.string("CANNOT_DELETE_PIPELINE_USED_AS_MATERIALS", pipelineConfig.name(), String.format("%s (%s)", pipeline.name(), pipeline.getOriginDisplayName()));
            this.result.unprocessableEntity(message);
            return false;
        }
    }
    for (EnvironmentConfig environment : preprocessedConfig.getEnvironments()) {
        if (environment.getPipelineNames().contains(pipelineConfig.name())) {
            Localizable.CurryableLocalizable message = LocalizedMessage.string("CANNOT_DELETE_PIPELINE_IN_ENVIRONMENT", pipelineConfig.name(), environment.name());
            this.result.unprocessableEntity(message);
            return false;
        }
    }
    return true;
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) EnvironmentConfig(com.thoughtworks.go.config.EnvironmentConfig) Localizable(com.thoughtworks.go.i18n.Localizable)

Example 20 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineHistoryController method list.

@RequestMapping(value = "/tab/pipeline/history", method = RequestMethod.GET)
public ModelAndView list(@RequestParam("pipelineName") String pipelineName) throws Exception {
    Map model = new HashMap();
    try {
        PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
        model.put("pipelineName", pipelineConfig.name());
        model.put("l", localizer);
        model.put("isEditableViaUI", goConfigService.isPipelineEditable(pipelineName));
        return new ModelAndView("pipeline/pipeline_history", model);
    } catch (PipelineNotFoundException e) {
        model.put("errorMessage", e.getMessage());
        return new ModelAndView("exceptions_page", model);
    }
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) PipelineNotFoundException(com.thoughtworks.go.config.PipelineNotFoundException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PipelineConfig (com.thoughtworks.go.config.PipelineConfig)285 Test (org.junit.jupiter.api.Test)185 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)142 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)52 TimeProvider (com.thoughtworks.go.util.TimeProvider)33 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)24 Test (org.junit.Test)23 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)21 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)19 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 Materials (com.thoughtworks.go.config.materials.Materials)14 Date (java.util.Date)14 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)13 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)13 StageConfig (com.thoughtworks.go.config.StageConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)12 Pipeline (com.thoughtworks.go.domain.Pipeline)12 Modification (com.thoughtworks.go.domain.materials.Modification)12