Search in sources :

Example 1 with DefaultSchedulingContext

use of com.thoughtworks.go.domain.DefaultSchedulingContext in project gocd by gocd.

the class PipelineWithRunOnAllJob method scheduleAndCompleteFollowingStages.

protected void scheduleAndCompleteFollowingStages(Pipeline pipeline, JobResult result) {
    Stage ft = new InstanceFactory().createStageInstance(ftStage(), new DefaultSchedulingContext("anyone"), "md5-test", new TimeProvider());
    ft.setOrderId(pipeline.getFirstStage().getOrderId() + 1);
    dbHelper.getStageDao().saveWithJobs(pipeline, ft);
    dbHelper.completeStage(ft, result);
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) InstanceFactory(com.thoughtworks.go.server.service.InstanceFactory) Stage(com.thoughtworks.go.domain.Stage) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext)

Example 2 with DefaultSchedulingContext

use of com.thoughtworks.go.domain.DefaultSchedulingContext in project gocd by gocd.

the class JobAgentMetadataSqlMapDaoIntegrationTest method setup.

@BeforeEach
public void setup() throws Exception {
    dbHelper.onSetUp();
    PipelineConfig pipelineConfig = PipelineMother.withSingleStageWithMaterials(PIPELINE_NAME, STAGE_NAME, BuildPlanMother.withBuildPlans(JOB_NAME, OTHER_JOB_NAME));
    DefaultSchedulingContext schedulingContext = new DefaultSchedulingContext(DEFAULT_APPROVED_BY);
    Pipeline savedPipeline = instanceFactory.createPipelineInstance(pipelineConfig, modifySomeFiles(pipelineConfig), schedulingContext, "md5-test", new TimeProvider());
    dbHelper.savePipelineWithStagesAndMaterials(savedPipeline);
    Stage savedStage = savedPipeline.getFirstStage();
    jobId = savedStage.getJobInstances().getByName(JOB_NAME).getId();
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) Stage(com.thoughtworks.go.domain.Stage) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext) Pipeline(com.thoughtworks.go.domain.Pipeline) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with DefaultSchedulingContext

use of com.thoughtworks.go.domain.DefaultSchedulingContext in project gocd by gocd.

the class BuildCauseProducerServiceWithFlipModificationTest method consume.

private void consume(final BuildCause buildCause) throws SQLException {
    dbHelper.saveRevs(buildCause.getMaterialRevisions());
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            Pipeline latestPipeline = pipelineScheduleQueue.createPipeline(buildCause, mingleConfig, new DefaultSchedulingContext(buildCause.getApprover(), new Agents()), "md5", new TimeProvider());
            // Pipeline latestPipeline = PipelineMother.schedule(mingleConfig, buildCause);
            pipelineDao.saveWithStages(latestPipeline);
            dbHelper.passStage(latestPipeline.getStages().first());
        }
    });
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) Agents(com.thoughtworks.go.config.Agents) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) Pipeline(com.thoughtworks.go.domain.Pipeline) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext)

Example 4 with DefaultSchedulingContext

use of com.thoughtworks.go.domain.DefaultSchedulingContext in project gocd by gocd.

the class PipelineWithMultipleStages method scheduleAndCompleteFollowingStages.

@Override
protected void scheduleAndCompleteFollowingStages(Pipeline pipeline, JobResult result) {
    for (int index = 2; index <= stagesSize; index++) {
        StageConfig stageConfig = stageConfig(index);
        Stage instance = new InstanceFactory().createStageInstance(stageConfig, new DefaultSchedulingContext("anyone"), "md5-test", new TimeProvider());
        instance.setOrderId(index);
        dbHelper.getStageDao().saveWithJobs(pipeline, instance);
        dbHelper.completeStage(instance, result);
    }
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) InstanceFactory(com.thoughtworks.go.server.service.InstanceFactory) Stage(com.thoughtworks.go.domain.Stage) StageConfig(com.thoughtworks.go.config.StageConfig) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext)

Aggregations

DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)4 TimeProvider (com.thoughtworks.go.util.TimeProvider)4 Stage (com.thoughtworks.go.domain.Stage)3 Pipeline (com.thoughtworks.go.domain.Pipeline)2 InstanceFactory (com.thoughtworks.go.server.service.InstanceFactory)2 Agents (com.thoughtworks.go.config.Agents)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 StageConfig (com.thoughtworks.go.config.StageConfig)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)1