use of com.thoughtworks.go.config.EnvironmentVariablesConfig in project gocd by gocd.
the class ScheduleStageTest method shouldResolveEnvironmentVariablesForJobReRun.
@Test
public void shouldResolveEnvironmentVariablesForJobReRun() {
Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
Stage oldStage = stageDao.stageByIdWithBuilds(pipeline.getStages().byName(fixture.devStage).getId());
EnvironmentVariablesConfig pipelineVariables = new EnvironmentVariablesConfig();
pipelineVariables.add("pipelineEnv", "pipelineFoo");
pipelineVariables.add("stageEnv", "pipelineBar");
pipelineVariables.add("jobEnv", "pipelineBaz");
configHelper.addEnvironmentVariableToPipeline(fixture.pipelineName, pipelineVariables);
EnvironmentVariablesConfig stageVariables = new EnvironmentVariablesConfig();
stageVariables.add("stageEnv", "stageBar");
stageVariables.add("jobEnv", "stageBaz");
configHelper.addEnvironmentVariableToStage(fixture.pipelineName, fixture.devStage, stageVariables);
EnvironmentVariablesConfig jobVariables = new EnvironmentVariablesConfig();
jobVariables.add("jobEnv", "jobBaz");
configHelper.addEnvironmentVariableToJob(fixture.pipelineName, fixture.devStage, fixture.JOB_FOR_DEV_STAGE, jobVariables);
Stage stage = scheduleService.rerunJobs(oldStage, a(fixture.JOB_FOR_DEV_STAGE), new HttpOperationResult());
EnvironmentVariables expectedVariableOrder = new EnvironmentVariables();
expectedVariableOrder.add("pipelineEnv", "pipelineFoo");
expectedVariableOrder.add("stageEnv", "stageBar");
expectedVariableOrder.add("jobEnv", "jobBaz");
JobInstances jobInstances = stage.getJobInstances();
assertThat(jobInstances.getByName(fixture.JOB_FOR_DEV_STAGE).getPlan().getVariables(), is(expectedVariableOrder));
}
use of com.thoughtworks.go.config.EnvironmentVariablesConfig in project gocd by gocd.
the class ScheduleStageTest method shouldResolveEnvironmentVariablesForStateReRun.
@Test
public void shouldResolveEnvironmentVariablesForStateReRun() throws Exception {
Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
EnvironmentVariablesConfig pipelineVariables = new EnvironmentVariablesConfig();
pipelineVariables.add("pipelineEnv", "pipelineFoo");
pipelineVariables.add("stageEnv", "pipelineBar");
pipelineVariables.add("jobEnv", "pipelineBaz");
configHelper.addEnvironmentVariableToPipeline(fixture.pipelineName, pipelineVariables);
EnvironmentVariablesConfig stageVariables = new EnvironmentVariablesConfig();
stageVariables.add("stageEnv", "stageBar");
stageVariables.add("jobEnv", "stageBaz");
configHelper.addEnvironmentVariableToStage(fixture.pipelineName, fixture.devStage, stageVariables);
EnvironmentVariablesConfig jobVariables = new EnvironmentVariablesConfig();
jobVariables.add("jobEnv", "jobBaz");
configHelper.addEnvironmentVariableToJob(fixture.pipelineName, fixture.devStage, fixture.JOB_FOR_DEV_STAGE, jobVariables);
Stage stage = scheduleService.rerunStage(pipeline.getName(), String.valueOf(pipeline.getCounter()), fixture.devStage);
dbHelper.passStage(stage);
EnvironmentVariables expectedVariableOrder = new EnvironmentVariables();
expectedVariableOrder.add("pipelineEnv", "pipelineFoo");
expectedVariableOrder.add("stageEnv", "stageBar");
expectedVariableOrder.add("jobEnv", "jobBaz");
JobInstances jobInstances = stage.getJobInstances();
assertThat(jobInstances.getByName(fixture.JOB_FOR_DEV_STAGE).getPlan().getVariables(), is(expectedVariableOrder));
}
use of com.thoughtworks.go.config.EnvironmentVariablesConfig in project gocd by gocd.
the class PipelineOperationsControllerV1Delegate method triggerOptions.
public String triggerOptions(Request request, Response response) throws IOException {
String pipelineName = request.params("pipeline_name");
EnvironmentVariablesConfig variables = goConfigService.variablesFor(pipelineName);
PipelineInstanceModel pipelineInstanceModel = pipelineHistoryService.latest(pipelineName, currentUsername());
TriggerOptions triggerOptions = new TriggerOptions(variables, pipelineInstanceModel);
return writerForTopLevelObject(request, response, writer -> TriggerWithOptionsViewRepresenter.toJSON(writer, triggerOptions));
}
Aggregations