Search in sources :

Example 6 with JobConfig

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

the class BuildWorkTest method getWork.

private static Work getWork(String jobXml, String pipelineName, boolean fetchMaterials, boolean cleanWorkingDir) throws Exception {
    CruiseConfig cruiseConfig = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(FileUtil.readToEnd(IOUtils.toInputStream(ConfigFileFixture.withJob(jobXml, pipelineName)))).config;
    JobConfig jobConfig = cruiseConfig.jobConfigByName(pipelineName, STAGE_NAME, JOB_PLAN_NAME, true);
    JobPlan jobPlan = JobInstanceMother.createJobPlan(jobConfig, new JobIdentifier(pipelineName, -2, PIPELINE_LABEL, STAGE_NAME, String.valueOf(STAGE_COUNTER), JOB_PLAN_NAME, 0L), new DefaultSchedulingContext());
    jobPlan.setFetchMaterials(fetchMaterials);
    jobPlan.setCleanWorkingDir(cleanWorkingDir);
    final Stage stage = StageMother.custom(STAGE_NAME, new JobInstance(JOB_PLAN_NAME));
    BuildCause buildCause = BuildCause.createWithEmptyModifications();
    final Pipeline pipeline = new Pipeline(pipelineName, buildCause, stage);
    pipeline.setLabel(PIPELINE_LABEL);
    List<Builder> builder = builderFactory.buildersForTasks(pipeline, jobConfig.getTasks(), resolver);
    BuildAssignment buildAssignment = BuildAssignment.create(jobPlan, BuildCause.createWithEmptyModifications(), builder, pipeline.defaultWorkingFolder());
    return new BuildWork(buildAssignment);
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) Builder(com.thoughtworks.go.domain.builder.Builder) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) JobConfig(com.thoughtworks.go.config.JobConfig) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 7 with JobConfig

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

the class NullStage method createNullStage.

public static NullStage createNullStage(StageConfig stageConfig) {
    JobInstances nullBuilds = new JobInstances();
    for (JobConfig plan : stageConfig.allBuildPlans()) {
        nullBuilds.add(new NullJobInstance(CaseInsensitiveString.str(plan.name())));
    }
    NullStage nullStage = new NullStage(CaseInsensitiveString.str(stageConfig.name()), nullBuilds);
    nullStage.setPipelineId(10l);
    return nullStage;
}
Also used : JobConfig(com.thoughtworks.go.config.JobConfig)

Example 8 with JobConfig

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

the class PipelineSqlMapDaoIntegrationTest method shouldNotIncludePipelinesNotUsingUpstreamAsDependencyMaterial_evenIfADependencyRevisionGeneratedOutOfParentPipelineAppearsInPMRrangeForANonDependentPipeline.

@Test
public void shouldNotIncludePipelinesNotUsingUpstreamAsDependencyMaterial_evenIfADependencyRevisionGeneratedOutOfParentPipelineAppearsInPMRrangeForANonDependentPipeline() throws Exception {
    // shine -> cruise(depends on shine)
    // mingle(not related to shine)
    final HgMaterial mingleHg = MaterialsMother.hgMaterial();
    PipelineConfig mingle = PipelineConfigMother.pipelineConfig("mingle", mingleHg.config(), new JobConfigs(new JobConfig("run-tests")));
    PipelineConfig shine = PipelineMother.twoBuildPlansWithResourcesAndMaterials("shine", "compile");
    Pipeline shineInstance = dbHelper.newPipelineWithAllStagesPassed(shine);
    PipelineConfig cruise = pipelineConfigFor("cruise", "shine", "compile");
    final DependencyMaterial cruiseUpstream = new DependencyMaterial(new CaseInsensitiveString("shine"), new CaseInsensitiveString("compile"));
    final Modification cruiseMod = new Modification(new Date(), String.format("shine/%s/compile/%s", shineInstance.getCounter(), shineInstance.getStages().get(0).getCounter()), "shine-1", null);
    final Modification mingleFrom = ModificationsMother.oneModifiedFile("1234");
    saveRev(mingleHg, mingleFrom);
    saveRev(cruiseUpstream, cruiseMod);
    final Modification mingleTo = ModificationsMother.oneModifiedFile("abcd");
    saveRev(mingleHg, mingleTo);
    dbHelper.saveMaterialsWIthPassedStages(instanceFactory.createPipelineInstance(mingle, BuildCause.createManualForced(new MaterialRevisions(new MaterialRevision(mingleHg, mingleTo, mingleFrom)), Username.ANONYMOUS), new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider()));
    final Pipeline cruiseInstance = instanceFactory.createPipelineInstance(cruise, BuildCause.createManualForced(new MaterialRevisions(new MaterialRevision(cruiseUpstream, cruiseMod)), Username.ANONYMOUS), new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider());
    dbHelper.saveMaterialsWIthPassedStages(cruiseInstance);
    PipelineDependencyGraphOld dependencyGraph = pipelineDao.pipelineGraphByNameAndCounter("shine", shineInstance.getCounter());
    assertPipelineEquals(shineInstance, dependencyGraph.pipeline());
    ensureBuildCauseIsLoadedFor(dependencyGraph.pipeline());
    PipelineInstanceModels dependencies = dependencyGraph.dependencies();
    assertThat(dependencies.size(), is(1));
    assertPipelineEquals(cruiseInstance, dependencies.find("cruise"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) JobConfig(com.thoughtworks.go.config.JobConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) JobConfigs(com.thoughtworks.go.config.JobConfigs) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Example 9 with JobConfig

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

the class SingleJobInstance method createRerunInstances.

public void createRerunInstances(JobInstance oldJob, JobInstances jobInstances, SchedulingContext context, StageConfig stageConfig, final Clock clock, InstanceFactory instanceFactory) {
    String jobName = oldJob.getName();
    JobConfig jobConfig = stageConfig.jobConfigByInstanceName(jobName, true);
    if (jobConfig == null) {
        throw new CannotRerunJobException(jobName, "Configuration for job doesn't exist.");
    }
    if (jobConfig.isRunMultipleInstanceType()) {
        String runType = "'run multiple instance'";
        throw new CannotRerunJobException(jobName, "Run configuration for job has been changed to " + runType + ".");
    }
    RunOnAllAgents.CounterBasedJobNameGenerator nameGenerator = new RunOnAllAgents.CounterBasedJobNameGenerator(CaseInsensitiveString.str(jobConfig.name()));
    JobInstances instances = instanceFactory.createJobInstance(stageConfig.name(), jobConfig, context, clock, nameGenerator);
    for (JobInstance instance : instances) {
        instance.setRerun(true);
    }
    jobInstances.addAll(instances);
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) JobConfig(com.thoughtworks.go.config.JobConfig)

Example 10 with JobConfig

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

the class BuildComposerTest method getAssigment.

private static BuildAssignment getAssigment(String jobXml, String pipelineName, boolean fetchMaterials, boolean cleanWorkingDir) throws Exception {
    CruiseConfig cruiseConfig = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(FileUtil.readToEnd(IOUtils.toInputStream(ConfigFileFixture.withJob(jobXml, pipelineName)))).config;
    JobConfig jobConfig = cruiseConfig.jobConfigByName(pipelineName, STAGE_NAME, JOB_PLAN_NAME, true);
    JobPlan jobPlan = JobInstanceMother.createJobPlan(jobConfig, new JobIdentifier(pipelineName, -2, PIPELINE_LABEL, STAGE_NAME, String.valueOf(STAGE_COUNTER), JOB_PLAN_NAME, 0L), new DefaultSchedulingContext());
    jobPlan.setFetchMaterials(fetchMaterials);
    jobPlan.setCleanWorkingDir(cleanWorkingDir);
    final Stage stage = StageMother.custom(STAGE_NAME, new JobInstance(JOB_PLAN_NAME));
    BuildCause buildCause = BuildCause.createWithEmptyModifications();
    final Pipeline pipeline = new Pipeline(pipelineName, buildCause, stage);
    pipeline.setLabel(PIPELINE_LABEL);
    List<Builder> builder = builderFactory.buildersForTasks(pipeline, jobConfig.getTasks(), resolver);
    return BuildAssignment.create(jobPlan, BuildCause.createWithEmptyModifications(), builder, pipeline.defaultWorkingFolder());
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) Builder(com.thoughtworks.go.domain.builder.Builder) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) JobConfig(com.thoughtworks.go.config.JobConfig) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Aggregations

JobConfig (com.thoughtworks.go.config.JobConfig)10 JobConfigs (com.thoughtworks.go.config.JobConfigs)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 ConfigCache (com.thoughtworks.go.config.ConfigCache)3 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)3 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)3 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)3 Builder (com.thoughtworks.go.domain.builder.Builder)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)2 Test (org.junit.Test)2 ArtifactPlan (com.thoughtworks.go.config.ArtifactPlan)1 PipelineTemplateConfig (com.thoughtworks.go.config.PipelineTemplateConfig)1 TemplatesConfig (com.thoughtworks.go.config.TemplatesConfig)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)1 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)1 Modification (com.thoughtworks.go.domain.materials.Modification)1 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)1 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)1 Date (java.util.Date)1