use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class ConsoleOutputTransmitterTest method setup.
@Before
public void setup() throws Exception {
initMocks(this);
// so the thread does not wake up
new SystemEnvironment().setProperty(SystemEnvironment.INTERVAL, "60");
requestArgumentCaptor = ArgumentCaptor.forClass(String.class);
doNothing().when(consoleAppender).append(requestArgumentCaptor.capture());
transmitter = new ConsoleOutputTransmitter(consoleAppender, 0, mock(ScheduledThreadPoolExecutor.class));
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class FileValidatorTest method setUp.
@Before
public void setUp() {
realConfigDir = new SystemEnvironment().getPropertyImpl("cruise.config.dir");
new SystemEnvironment().setProperty("cruise.config.dir", new SystemEnvironment().getPropertyImpl("java.io.tmpdir"));
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class SleepWork method doWork.
@Override
public void doWork(EnvironmentVariableContext environmentVariableContext, AgentWorkContext agentWorkContext) {
cancelLatch = new CountDownLatch(1);
agentWorkContext.getAgentRuntimeInfo().busy(new AgentBuildingInfo("sleepwork", "sleepwork1"));
boolean canceled = false;
DefaultGoPublisher goPublisher = new DefaultGoPublisher(agentWorkContext.getArtifactsManipulator(), new JobIdentifier(), agentWorkContext.getRepositoryRemote(), agentWorkContext.getAgentRuntimeInfo(), "utf-8");
try {
if (this.sleepInMilliSeconds > 0) {
canceled = cancelLatch.await(this.sleepInMilliSeconds, TimeUnit.MILLISECONDS);
}
String result = canceled ? "done_canceled" : "done";
agentWorkContext.getArtifactsManipulator().setProperty(null, new Property(name + "_result", result));
SystemEnvironment systemEnvironment = new SystemEnvironment();
if (systemEnvironment.isConsoleLogsThroughWebsocketEnabled() && systemEnvironment.isWebsocketsForAgentsEnabled()) {
goPublisher.consumeLine(format("Sleeping for %s milliseconds", this.sleepInMilliSeconds));
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class ServerConfigTest method shouldNotUpdatePasswordForMailHostIfNotChangedOrNull.
@Test
public void shouldNotUpdatePasswordForMailHostIfNotChangedOrNull() throws InvalidCipherTextException, IOException {
File cipherFile = new SystemEnvironment().getCipherFile();
FileUtils.deleteQuietly(cipherFile);
FileUtils.writeStringToFile(cipherFile, "269298bc31c44620", UTF_8);
GoCipher goCipher = new GoCipher();
MailHost mailHost = new MailHost("abc", 12, "admin", "p", null, true, true, "anc@mail.com", "anc@mail.com", goCipher);
ServerConfig serverConfig = new ServerConfig(null, mailHost, null, null);
assertThat(serverConfig.mailHost().getPassword(), Is.is("p"));
String encryptedPassword = serverConfig.mailHost().getEncryptedPassword();
serverConfig.updateMailHost(new MailHost("abc", 12, "admin", "p", encryptedPassword, false, /* Password Not Changed */
true, "anc@mail.com", "anc@mail.com", goCipher));
assertThat(serverConfig.mailHost().getPassword(), Is.is("p"));
assertThat(serverConfig.mailHost().getEncryptedPassword(), Is.is(encryptedPassword));
serverConfig.updateMailHost(new MailHost("abc", 12, "admin", null, "", true, true, "anc@mail.com", "anc@mail.com"));
assertThat(serverConfig.mailHost().getPassword(), Is.is(""));
assertThat(serverConfig.mailHost().getEncryptedPassword(), Is.is(nullValue()));
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class ScheduledPipelineLoader method knownMaterials.
private MaterialConfigs knownMaterials(Pipeline pipeline, MaterialRevisions scheduledRevs) {
CruiseConfig currentConfig = goConfigService.getCurrentConfig();
MaterialConfigs configuredMaterials = new MaterialConfigs();
for (MaterialRevision revision : scheduledRevs) {
String fingerprint = revision.getMaterial().getFingerprint();
// first try to find material config from current pipeline config
MaterialConfig configuredMaterial = currentConfig.materialConfigFor(new CaseInsensitiveString(pipeline.getName()), fingerprint);
if (configuredMaterial != null) {
configuredMaterials.add(configuredMaterial);
continue;
}
// todo: remove the global lookup fallback code after we feel safe
if (new SystemEnvironment().get(SystemEnvironment.GO_SERVER_SCHEDULED_PIPELINE_LOADER_GLOBAL_MATERIAL_LOOKUP)) {
// fallback to global lookup if material is not in current pipeline config (old behavior)
configuredMaterial = currentConfig.materialConfigFor(fingerprint);
if (configuredMaterial != null) {
configuredMaterials.add((configuredMaterial));
}
}
}
MaterialConfigs knownMaterials = new MaterialConfigs();
for (MaterialConfig configuredMaterial : configuredMaterials) {
materialExpansionService.expandForScheduling(configuredMaterial, knownMaterials);
}
return knownMaterials;
}
Aggregations