public void Write(OctoVersionInfo octoVersionInfo) { const string prefix = ConfigurationBootstrapper.EnvironmentVariablePrefix; var properties = octoVersionInfo.GetType() .GetProperties(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance); foreach (var property in properties) { var key = $"{prefix}{property.Name}"; var value = property.GetValue(octoVersionInfo)?.ToString() ?? string.Empty; var line = $"{key}={value}"; System.Console.WriteLine(line); } }
static void WriteEnvironmentVariables(OctoVersionInfo octoVersionInfo) { // ##teamcity[setParameter name='ddd' value='fff'] const string prefix = ConfigurationBootstrapper.EnvironmentVariablePrefix; var properties = octoVersionInfo.GetType() .GetProperties(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance); foreach (var property in properties) { var environmentVariableKey = $"env.{prefix}{property.Name}"; var configurationVariableKey = $"OctoVersion.{property.Name}"; var value = property.GetValue(octoVersionInfo)?.ToString() ?? string.Empty; var environmentVariableMessage = $"##teamcity[setParameter name='{environmentVariableKey}' value='{value}']"; System.Console.WriteLine(environmentVariableMessage); var configurationVariableMessage = $"##teamcity[setParameter name='{configurationVariableKey}' value='{value}']"; System.Console.WriteLine(configurationVariableMessage); } }