use of com.thoughtworks.go.server.scheduling.ScheduleOptions in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTest method shouldSchedulePipelineWithManualFirstStageWhenManuallyTriggered.
@Test
public void shouldSchedulePipelineWithManualFirstStageWhenManuallyTriggered() throws Exception {
configHelper.configureStageAsManualApproval(MINGLE_PIPELINE_NAME, STAGE_NAME);
svnRepository.checkInOneFile("a.java");
materialDatabaseUpdater.updateMaterial(svnRepository.material());
final HashMap<String, String> revisions = new HashMap<>();
final HashMap<String, String> environmentVariables = new HashMap<>();
buildCauseProducer.manualProduceBuildCauseAndSave(MINGLE_PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
Map<String, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(5);
assertThat(afterLoad.keySet(), hasItem(MINGLE_PIPELINE_NAME));
BuildCause cause = afterLoad.get(MINGLE_PIPELINE_NAME);
assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
}
use of com.thoughtworks.go.server.scheduling.ScheduleOptions 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;
}
use of com.thoughtworks.go.server.scheduling.ScheduleOptions in project gocd by gocd.
the class ScheduleServiceIntegrationTest method manualSchedule.
private Pipeline manualSchedule(String pipelineName) {
final HashMap<String, String> revisions = new HashMap<>();
final HashMap<String, String> environmentVariables = new HashMap<>();
final HashMap<String, String> secureEnvironmentVariables = new HashMap<>();
buildCauseProducer.manualProduceBuildCauseAndSave(pipelineName, new Username(new CaseInsensitiveString("some user name")), new ScheduleOptions(revisions, environmentVariables, secureEnvironmentVariables), new ServerHealthStateOperationResult());
scheduleService.autoSchedulePipelinesFromRequestBuffer();
return pipelineService.mostRecentFullPipelineByName(pipelineName);
}
use of com.thoughtworks.go.server.scheduling.ScheduleOptions in project gocd by gocd.
the class ScheduleServiceRunOnAllAgentIntegrationTest method manualSchedule.
private Pipeline manualSchedule(String pipelineName) {
final HashMap<String, String> revisions = new HashMap<>();
final HashMap<String, String> environmentVariables = new HashMap<>();
buildCauseProducer.manualProduceBuildCauseAndSave(pipelineName, new Username(new CaseInsensitiveString("some user name")), new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
scheduleService.autoSchedulePipelinesFromRequestBuffer();
return pipelineService.mostRecentFullPipelineByName(pipelineName);
}
use of com.thoughtworks.go.server.scheduling.ScheduleOptions in project gocd by gocd.
the class PipelineSchedulerIntegrationTest method shouldPassOverriddenEnvironmentVariablesForScheduling.
@Test
public void shouldPassOverriddenEnvironmentVariablesForScheduling() {
final ScheduleOptions scheduleOptions = new ScheduleOptions(new HashMap<>(), Collections.singletonMap("KEY", "value"), new HashMap<>());
HttpOperationResult operationResult = new HttpOperationResult();
goConfigService.pipelineConfigNamed(new CaseInsensitiveString(PIPELINE_MINGLE)).setVariables(env("KEY", "somejunk"));
serverHealthService.update(ServerHealthState.failToScheduling(HealthStateType.general(HealthStateScope.forPipeline(PIPELINE_MINGLE)), PIPELINE_MINGLE, "should wait till cleared"));
pipelineScheduler.manualProduceBuildCauseAndSave(PIPELINE_MINGLE, Username.ANONYMOUS, scheduleOptions, operationResult);
assertThat(operationResult.message(), operationResult.canContinue(), is(true));
Assertions.waitUntil(Timeout.ONE_MINUTE, new Assertions.Predicate() {
public boolean call() throws Exception {
return serverHealthService.filterByScope(HealthStateScope.forPipeline(PIPELINE_MINGLE)).size() == 0;
}
});
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(PIPELINE_MINGLE);
EnvironmentVariables overriddenVariables = buildCause.getVariables();
assertThat(overriddenVariables, is(new EnvironmentVariables(Arrays.asList(new EnvironmentVariable("KEY", "value")))));
}
Aggregations