Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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)));
 }
Exemple #6
0
        public void WindowsEnvironmentVariableReplaced(string inputValue, string expectedResult)
        {
            var value = CrossPlatform.ExpandPathEnvironmentVariables(inputValue);

            Assert.AreEqual(expectedResult, value);
        }