use of com.thoughtworks.go.domain.EnvironmentVariables in project gocd by gocd.
the class EnvironmentVariableSqlMapDao method load.
@Override
public EnvironmentVariables load(final Long entityId, final EnvironmentVariableType type) {
List<EnvironmentVariable> result = (List<EnvironmentVariable>) transactionTemplate.execute((TransactionCallback) transactionStatus -> {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(EnvironmentVariable.class).add(Restrictions.eq("entityId", entityId)).add(Restrictions.eq("entityType", type.toString())).addOrder(Order.asc("id"));
criteria.setCacheable(true);
return criteria.list();
});
return new EnvironmentVariables(result);
}
use of com.thoughtworks.go.domain.EnvironmentVariables in project gocd by gocd.
the class EnvironmentVariableSqlMapDaoIntegrationTest method shouldSaveSecureEnvironmentVariable.
@Test
public void shouldSaveSecureEnvironmentVariable() {
EnvironmentVariables variables = new EnvironmentVariables();
String plainText = "plainText";
String key = "key";
variables.add(new EnvironmentVariable(key, plainText, true));
dao.save(1L, Job, variables);
EnvironmentVariables actual = dao.load(1L, Job);
assertThat(actual.get(0).getName(), is(key));
assertThat(actual.get(0).getValue(), is(plainText));
assertThat(actual.get(0).isSecure(), is(true));
}
use of com.thoughtworks.go.domain.EnvironmentVariables in project gocd by gocd.
the class EnvironmentVariableSqlMapDaoIntegrationTest method shouldDeleteEnvironmentVariable.
@Test
public void shouldDeleteEnvironmentVariable() throws Exception {
EnvironmentVariables variables = new EnvironmentVariables();
String plainText = "plainText";
String key = "key";
variables.add(new EnvironmentVariable(key, plainText, false));
dao.save(1L, Job, variables);
EnvironmentVariables variableFromDb = dao.load(1L, Job);
assertThat(variableFromDb.size(), is(1));
dao.deleteAll(variableFromDb);
variableFromDb = dao.load(1L, Job);
assertThat(variableFromDb.size(), is(0));
}
use of com.thoughtworks.go.domain.EnvironmentVariables in project gocd by gocd.
the class EnvironmentVariableSqlMapDaoIntegrationTest method shouldSavePlainTextEnvironmentVariable.
@Test
public void shouldSavePlainTextEnvironmentVariable() {
EnvironmentVariables variables = new EnvironmentVariables();
String plainText = "plainText";
String key = "key";
variables.add(new EnvironmentVariable(key, plainText, false));
dao.save(1L, Job, variables);
EnvironmentVariables actual = dao.load(1L, Job);
assertThat(actual.get(0).getName(), is(key));
assertThat(actual.get(0).getValue(), is(plainText));
assertThat(actual.get(0).isSecure(), is(false));
}
use of com.thoughtworks.go.domain.EnvironmentVariables 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 BooleanSupplier() {
@Override
public boolean getAsBoolean() {
return serverHealthService.filterByScope(HealthStateScope.forPipeline(PIPELINE_MINGLE)).size() == 0;
}
});
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(new CaseInsensitiveString(PIPELINE_MINGLE));
EnvironmentVariables overriddenVariables = buildCause.getVariables();
assertThat(overriddenVariables, is(new EnvironmentVariables(Arrays.asList(new EnvironmentVariable("KEY", "value")))));
}
Aggregations