public void TildePrefixReplacedWithHome() { var home = Environment.GetEnvironmentVariable("HOME"); Assert.IsNotNull(home, "Expected $HOME environment variable to be set."); var value = CrossPlatform.ExpandPathEnvironmentVariables("~/blah"); Assert.AreEqual($"{home}/blah", value); }
public void TildePrefixReplacedWithHome() { // This usage of Environment.GetEnvironmentVariable is fine as it's not accessing a test dependency variable var home = Environment.GetEnvironmentVariable("HOME"); Assert.IsNotNull(home, "Expected $HOME environment variable to be set."); var value = CrossPlatform.ExpandPathEnvironmentVariables("~/blah"); Assert.AreEqual($"{home}/blah", value); }
public void Install(RunningDeployment deployment) { var transferPath = CrossPlatform.ExpandPathEnvironmentVariables(deployment.Variables.Get(PackageVariables.TransferPath)); fileSystem.EnsureDirectoryExists(transferPath); var fileName = deployment.Variables.Get(PackageVariables.OriginalFileName) ?? Path.GetFileName(deployment.PackageFilePath); var filePath = Path.Combine(transferPath, fileName); if (fileSystem.FileExists(filePath)) { log.Info($"File {filePath} already exists so it will be attempted to be overwritten"); } fileSystem.CopyFile(deployment.PackageFilePath, filePath); log.Info($"Copied package '{fileName}' to directory '{transferPath}'"); log.SetOutputVariableButDoNotAddToVariables(PackageVariables.Output.DirectoryPath, transferPath); log.SetOutputVariableButDoNotAddToVariables(PackageVariables.Output.FileName, fileName); log.SetOutputVariableButDoNotAddToVariables(PackageVariables.Output.FilePath, filePath); }
public static PathToPackage GetPathToPrimaryPackage(this IVariables variables, ICalamariFileSystem fileSystem, bool required) { var path = variables.Get(TentacleVariables.CurrentDeployment.PackageFilePath); if (string.IsNullOrEmpty(path)) { if (required) { throw new CommandException($"The `{TentacleVariables.CurrentDeployment.PackageFilePath}` was not specified or blank. This is likely a bug in Octopus, please contact Octopus support."); } else { return(null); } } path = CrossPlatform.ExpandPathEnvironmentVariables(path); if (!fileSystem.FileExists(path)) { throw new CommandException("Could not find package file: " + path); } return(new PathToPackage(path)); }
public string GetEnvironmentExpandedPath(string variableName, string defaultValue = null) { return(CrossPlatform.ExpandPathEnvironmentVariables(Get(variableName, defaultValue))); }
public void WindowsEnvironmentVariableReplaced(string inputValue, string expectedResult) { var value = CrossPlatform.ExpandPathEnvironmentVariables(inputValue); Assert.AreEqual(expectedResult, value); }