Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variable enumeration for bash #1441

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion source/Calamari.Common/FeatureToggles/FeatureToggle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum FeatureToggle {
KubernetesLiveObjectStatusFeatureToggle,
KubernetesAuthAwsCliWithExecFeatureToggle,
ForceUtf8ZipFileDecodingFeatureToggle,
DisableFSharpScriptExecutionFeatureToggle
DisableFSharpScriptExecutionFeatureToggle,
BashParametersArrayFeatureToggle
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text;
using Calamari.Common.Features.Processes;
using Calamari.Common.Features.Scripts;
using Calamari.Common.FeatureToggles;
using Calamari.Common.Plumbing;
using Calamari.Common.Plumbing.Extensions;
using Calamari.Common.Plumbing.FileSystem;
Expand Down Expand Up @@ -44,6 +45,9 @@ public static string PrepareConfigurationFile(string workingDirectory, IVariable
var encryptedVariables = EncryptVariables(variables);
builder.Replace("#### VariableDeclarations ####", string.Join(LinuxNewLine, GetVariableSwitchConditions(encryptedVariables)));

builder.Replace("#### BashParametersArrayFeatureToggle ####", FeatureToggle.BashParametersArrayFeatureToggle.IsEnabled(variables) ? "true" : "false");
builder.Replace("#### VariableNamesArrayDeclarations ####", FeatureToggle.BashParametersArrayFeatureToggle.IsEnabled(variables) ? string.Join(" ", GetVariableNameAndValueDeclaration(encryptedVariables)) : string.Empty);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only replace the variableNamesArrayDecleration if the feature toggle is enabled. This prevents any malformed variables from breaking the bash script if the toggle is disabled.


using (var file = new FileStream(configurationFile, FileMode.CreateNew, FileAccess.Write))
using (var writer = new StreamWriter(file, Encoding.ASCII))
{
Expand All @@ -55,6 +59,15 @@ public static string PrepareConfigurationFile(string workingDirectory, IVariable
return configurationFile;
}

static IEnumerable<string> GetVariableNameAndValueDeclaration(IEnumerable<EncryptedVariable> variables)
{
return variables.Select(variable =>
{
var variableValue = $@"$(get_octopusvariable ""{variable.Name.Replace("\"", "\\\"")}"")";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far the only case I've found that I have to manually add delimiters to is ". This is because the final generated command has the format:

 declare -grA octopus_parameters=(["Octopus.Agent.ProgramDirectoryPath"]="$(get_octopusvariable "Octopus.Agent.ProgramDirectoryPath")" ["Octopus.Sashimi.ScriptFunctions.Registration"]="$(get_octopusvariable "Octopus.Sashimi.ScriptFunctions.Registration")" ["Octopus.Deployment.Id"]="$(get_octopusvariable "Octopus.Deployment.Id")" ["Octopus.Deployment.Name"]="$(get_octopusvariable "Octopus.Deployment.Name")" ["Octopus.Deployment.Created"]="$(get_octopusvariable "Octopus.Deployment.Created")" ["Octopus.Deployment.CreatedUtc"]="$(get_octopusvariable "Octopus.Deployment.CreatedUtc")"

Copy link
Contributor

@benPearce1 benPearce1 Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backtick characters also need to be escaped.

image image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up raising an issue
OctopusDeploy/Issues#9255

Copy link
Contributor Author

@IsaacCalligeros95 IsaacCalligeros95 Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm calling get_octopusvariable to avoid passing through the encrypted variables etc a second time. Generally this should involve less characters in the final bash script but the generated command is large. I still need to do some performance testing on this but it's instant on a local project with minimal variables.

if [ "$bashParametersArrayFeatureToggle" = true ]; then
    if (( ${BASH_VERSINFO[0]} > 4 || (${BASH_VERSINFO[0]} == 4 && ${BASH_VERSINFO[1]} > 2) )); then
      declare -grA octopus_parameters=(["Octopus.Agent.ProgramDirectoryPath"]="$(get_octopusvariable "Octopus.Agent.ProgramDirectoryPath")" ["Octopus.Sashimi.ScriptFunctions.Registration"]="$(get_octopusvariable "Octopus.Sashimi.ScriptFunctions.Registration")" ["Octopus.Deployment.Id"]="$(get_octopusvariable "Octopus.Deployment.Id")" ["Octopus.Deployment.Name"]="$(get_octopusvariable "Octopus.Deployment.Name")" ["Octopus.Deployment.Created"]="$(get_octopusvariable "Octopus.Deployment.Created")" ["Octopus.Deployment.CreatedUtc"]="$(get_octopusvariable "Octopus.Deployment.CreatedUtc")" ["Octopus.Deployment.Comments"]="$(get_octopusvariable "Octopus.Deployment.Comments")" ["Octopus.Deployment.ForcePackageDownload"]="$(get_octopusvariable "Octopus.Deployment.ForcePackageDownload")" ["Octopus.Deployment.SpecificMachines"]="$(get_octopusvariable "Octopus.Deployment.SpecificMachines")" ["Octopus.Deployment.ExcludedMachines"]="$(get_octopusvariable "Octopus.Deployment.ExcludedMachines")" ["Octopus.Project.Id"]="$(get_octopusvariable "Octopus.Project.Id")" ["Octopus.Project.Name"]="$(get_octopusvariable "Octopus.Project.Name")" ["Octopus.Project.Slug"]="$(get_octopusvariable "Octopus.Project.Slug")" ["Octopus.ProjectGroup.Id"]="$(get_octopusvariable "Octopus.ProjectGroup.Id")" ["Octopus.ProjectGroup.Name"]="$(get_octopusvariable "Octopus.ProjectGroup.Name")" ["Octopus.Environment.Id"]="$(get_octopusvariable "Octopus.Environment.Id")" ["Octopus.Environment.Name"]="$(get_octopusvariable "Octopus.Environment.Name")" ["Octopus.Environment.SortOrder"]="$(get_octopusvariable "Octopus.Environment.SortOrder")" ["Octopus.Release.Id"]="$(get_octopusvariable "Octopus.Release.Id")" ["Octopus.Release.Number"]="$(get_octopusvariable "Octopus.Release.Number")" ["Octopus.Release.Created"]="$(get_octopusvariable "Octopus.Release.Created")" ["Octopus.Release.CreatedUtc"]="$(get_octopusvariable "Octopus.Release.CreatedUtc")" ["Octopus.Release.Notes"]="$(get_octopusvariable "Octopus.Release.Notes")" ["Octopus.Task.Id"]="$(get_octopusvariable "Octopus.Task.Id")" ["Octopus.Task.Name"]="$(get_octopusvariable "Octopus.Task.Name")" ["Octopus.Task.QueueTime"]="$(get_octopusvariable "Octopus.Task.QueueTime")" ["Octopus.Task.QueueTimeExpiry"]="$(get_octopusvariable "Octopus.Task.QueueTimeExpiry")" ["Octopus.Task.Argument[DeploymentId]"]="$(get_octopusvariable "Octopus.Task.Argument[DeploymentId]")" ["Octopus.Release.Channel.Id"]="$(get_octopusvariable "Octopus.Release.Channel.Id")" ["Octopus.Release.Channel.Name"]="$(get_octopusvariable "Octopus.Release.Channel.Name")" ["Octopus.Space.Id"]="$(get_octopusvariable "Octopus.Space.Id")" ["Octopus.Space.Name"]="$(get_octopusvariable "Octopus.Space.Name")" ["Octopus.Web.BaseUrl"]="$(get_octopusvariable "Octopus.Web.BaseUrl")" ["Octopus.Web.ServerUri"]="$(get_octopusvariable "Octopus.Web.ServerUri")" ["Octopus.Web.DeploymentLink"]="$(get_octopusvariable "Octopus.Web.DeploymentLink")" ["Octopus.Web.ReleaseLink"]="$(get_octopusvariable "Octopus.Web.ReleaseLink")" ["Octopus.Web.ProjectLink"]="$(get_octopusvariable "Octopus.Web.ProjectLink")" ["Octopus.Action.Number"]="$(get_octopusvariable "Octopus.Action.Number")" ["Octopus.Action.StepName"]="$(get_octopusvariable "Octopus.Action.StepName")" ["Octopus.Step.Number"]="$(get_octopusvariable "Octopus.Step.Number")" ["Octopus.Step.Id"]="$(get_octopusvariable "Octopus.Step.Id")" ["Octopus.Step.Name"]="$(get_octopusvariable "Octopus.Step.Name")" ["Octopus.Action.TargetRoles"]="$(get_octopusvariable "Octopus.Action.TargetRoles")" ["Octopus.Action.Id"]="$(get_octopusvariable "Octopus.Action.Id")" ["Octopus.Action.Name"]="$(get_octopusvariable "Octopus.Action.Name")" ["OctopusUseBundledTooling"]="$(get_octopusvariable "OctopusUseBundledTooling")" ["Octopus.Action.RunOnServer"]="$(get_octopusvariable "Octopus.Action.RunOnServer")" ["Octopus.Action.Script.ScriptSource"]="$(get_octopusvariable "Octopus.Action.Script.ScriptSource")" ["Octopus.Action.Script.Syntax"]="$(get_octopusvariable "Octopus.Action.Script.Syntax")" ["Octopus.Action.Script.ScriptBody"]="$(get_octopusvariable "Octopus.Action.Script.ScriptBody")" ["Octopus.Action.Container.Image"]="$(get_octopusvariable "Octopus.Action.Container.Image")" ["Octopus.Action.Container.Feed"]="$(get_octopusvariable "Octopus.Action.Container.Feed")" ["Octopus.Action.Container.GitUrl"]="$(get_octopusvariable "Octopus.Action.Container.GitUrl")" ["Octopus.Action.Container.Dockerfile"]="$(get_octopusvariable "Octopus.Action.Container.Dockerfile")" ["Octopus.Step[Run a Script].Number"]="$(get_octopusvariable "Octopus.Step[Run a Script].Number")" ["Octopus.Step[Run a Script].Id"]="$(get_octopusvariable "Octopus.Step[Run a Script].Id")" ["Octopus.Step[Run a Script].Name"]="$(get_octopusvariable "Octopus.Step[Run a Script].Name")" ["Octopus.Deployment.CreatedBy.Id"]="$(get_octopusvariable "Octopus.Deployment.CreatedBy.Id")" ["Octopus.Deployment.CreatedBy.Username"]="$(get_octopusvariable "Octopus.Deployment.CreatedBy.Username")" ["Octopus.Deployment.CreatedBy.DisplayName"]="$(get_octopusvariable "Octopus.Deployment.CreatedBy.DisplayName")" ["Octopus.Deployment.CreatedBy.EmailAddress"]="$(get_octopusvariable "Octopus.Deployment.CreatedBy.EmailAddress")" ["Octopus.Tentacle.CurrentDeployment.RetentionPolicySubset"]="$(get_octopusvariable "Octopus.Tentacle.CurrentDeployment.RetentionPolicySubset")" ["OctopusRetentionPolicySet"]="$(get_octopusvariable "OctopusRetentionPolicySet")" ["OctopusRetentionPolicyItemsToKeep"]="$(get_octopusvariable "OctopusRetentionPolicyItemsToKeep")" ["OctopusUseGuidedFailure"]="$(get_octopusvariable "OctopusUseGuidedFailure")" ["Secrety!"]="$(get_octopusvariable "Secrety!")" ["test 'hello'"]="$(get_octopusvariable "test 'hello'")" ["key.2"]="$(get_octopusvariable "key.2")" ["Octopus.Calamari.Executable"]="$(get_octopusvariable "Octopus.Calamari.Executable")" ["Single"quote"]="$(get_octopusvariable "Single"quote")" ["t't"]="$(get_octopusvariable "t't")" ["Octopus.Calamari.CopyWorkingDirectoryIncludingKeyTo"]="$(get_octopusvariable "Octopus.Calamari.CopyWorkingDirectoryIncludingKeyTo")" ["Octopus.Release.Previous.Id"]="$(get_octopusvariable "Octopus.Release.Previous.Id")" ["Octopus.Release.Previous.Number"]="$(get_octopusvariable "Octopus.Release.Previous.Number")" ["Octopus.Release.PreviousForEnvironment.Id"]="$(get_octopusvariable "Octopus.Release.PreviousForEnvironment.Id")" ["Octopus.Release.PreviousForEnvironment.Number"]="$(get_octopusvariable "Octopus.Release.PreviousForEnvironment.Number")" ["Octopus.Release.CurrentForEnvironment.Id"]="$(get_octopusvariable "Octopus.Release.CurrentForEnvironment.Id")" ["Octopus.Release.CurrentForEnvironment.Number"]="$(get_octopusvariable "Octopus.Release.CurrentForEnvironment.Number")" ["Octopus.Deployment.PreviousSuccessful.Id"]="$(get_octopusvariable "Octopus.Deployment.PreviousSuccessful.Id")" ["Octopus.Calamari.ArchiveLimits.Enabled"]="$(get_octopusvariable "Octopus.Calamari.ArchiveLimits.Enabled")" ["Octopus.Calamari.ArchiveLimits.Metrics.Enabled"]="$(get_octopusvariable "Octopus.Calamari.ArchiveLimits.Metrics.Enabled")" ["Octopus.Calamari.ArchiveLimits.MaximumCompressionRatio"]="$(get_octopusvariable "Octopus.Calamari.ArchiveLimits.MaximumCompressionRatio")" ["Octopus.Calamari.ArchiveLimits.MaximumUncompressedSize"]="$(get_octopusvariable "Octopus.Calamari.ArchiveLimits.MaximumUncompressedSize")" ["Octopus.Deployment.WorkItems"]="$(get_octopusvariable "Octopus.Deployment.WorkItems")" ["Octopus.Deployment.PackageBuildInformation"]="$(get_octopusvariable "Octopus.Deployment.PackageBuildInformation")" ["Octopus.Deployment.PackageBuildMetadata"]="$(get_octopusvariable "Octopus.Deployment.PackageBuildMetadata")" ["Octopus.Deployment.Changes"]="$(get_octopusvariable "Octopus.Deployment.Changes")" ["OctopusEnabledFeatureToggles"]="$(get_octopusvariable "OctopusEnabledFeatureToggles")" ["Octopus.Deployment.ChangesMarkdown"]="$(get_octopusvariable "Octopus.Deployment.ChangesMarkdown")" ["Octopus.Deployment.Machines"]="$(get_octopusvariable "Octopus.Deployment.Machines")" ["Octopus.Environment.MachinesInRole[isaacwel]"]="$(get_octopusvariable "Octopus.Environment.MachinesInRole[isaacwel]")" ["Octopus.Machine.Id"]="$(get_octopusvariable "Octopus.Machine.Id")" ["Octopus.Machine.Name"]="$(get_octopusvariable "Octopus.Machine.Name")" ["Octopus.Tentacle.Agent.ApplicationDirectoryPath"]="$(get_octopusvariable "Octopus.Tentacle.Agent.ApplicationDirectoryPath")" ["Octopus.Tentacle.Agent.InstanceName"]="$(get_octopusvariable "Octopus.Tentacle.Agent.InstanceName")" ["Octopus.Tentacle.Agent.ProgramDirectoryPath"]="$(get_octopusvariable "Octopus.Tentacle.Agent.ProgramDirectoryPath")" ["Octopus.Machine.CommunicationStyle"]="$(get_octopusvariable "Octopus.Machine.CommunicationStyle")" ["Octopus.Machine.DeploymentTargetType"]="$(get_octopusvariable "Octopus.Machine.DeploymentTargetType")" ["Octopus.Machine.Hostname"]="$(get_octopusvariable "Octopus.Machine.Hostname")" ["Octopus.Machine.Roles"]="$(get_octopusvariable "Octopus.Machine.Roles")" ["Octopus.Machine.Tags"]="$(get_octopusvariable "Octopus.Machine.Tags")" ["Octopus.Machine.TenantIds"]="$(get_octopusvariable "Octopus.Machine.TenantIds")" ["Octopus.Step[Run a Script].Status.Code"]="$(get_octopusvariable "Octopus.Step[Run a Script].Status.Code")" ["Octopus.Action[Run a Script].Output.Octopus.Action.ExecutionContext.Location"]="$(get_octopusvariable "Octopus.Action[Run a Script].Output.Octopus.Action.ExecutionContext.Location")" ["Octopus.Action[Run a Script].Output.Octopus.Action.ExecutionContext.WorkerId"]="$(get_octopusvariable "Octopus.Action[Run a Script].Output.Octopus.Action.ExecutionContext.WorkerId")" ["Octopus.Action[Run a Script].Output.Octopus.Action.ExecutionContext.IsDynamicWorker"]="$(get_octopusvariable "Octopus.Action[Run a Script].Output.Octopus.Action.ExecutionContext.IsDynamicWorker")" ["Octopus.Action[Run a Script].Number"]="$(get_octopusvariable "Octopus.Action[Run a Script].Number")" ["Octopus.Action[Run a Script].StepName"]="$(get_octopusvariable "Octopus.Action[Run a Script].StepName")" ["Octopus.Action[Run a Script].TargetRoles"]="$(get_octopusvariable "Octopus.Action[Run a Script].TargetRoles")" ["Octopus.Action[Run a Script].Id"]="$(get_octopusvariable "Octopus.Action[Run a Script].Id")" ["Octopus.Action[Run a Script].Name"]="$(get_octopusvariable "Octopus.Action[Run a Script].Name")" ["Octopus.Action[Run a Script].RunOnServer"]="$(get_octopusvariable "Octopus.Action[Run a Script].RunOnServer")" ["Octopus.Action[Run a Script].Script.ScriptSource"]="$(get_octopusvariable "Octopus.Action[Run a Script].Script.ScriptSource")" ["Octopus.Action[Run a Script].Script.Syntax"]="$(get_octopusvariable "Octopus.Action[Run a Script].Script.Syntax")" ["Octopus.Action[Run a Script].Script.ScriptBody"]="$(get_octopusvariable "Octopus.Action[Run a Script].Script.ScriptBody")" ["Octopus.Action[Run a Script].Container.Image"]="$(get_octopusvariable "Octopus.Action[Run a Script].Container.Image")" ["Octopus.Action[Run a Script].Container.Feed"]="$(get_octopusvariable "Octopus.Action[Run a Script].Container.Feed")" ["Octopus.Action[Run a Script].Container.GitUrl"]="$(get_octopusvariable "Octopus.Action[Run a Script].Container.GitUrl")" ["Octopus.Action[Run a Script].Container.Dockerfile"]="$(get_octopusvariable "Octopus.Action[Run a Script].Container.Dockerfile")" ["Octopus.Action[Run a Script].Output[isaac wsl].Octopus.Action.ExecutionContext.Location"]="$(get_octopusvariable "Octopus.Action[Run a Script].Output[isaac wsl].Octopus.Action.ExecutionContext.Location")" ["Octopus.Action[Run a Script].Output[isaac wsl].Octopus.Action.ExecutionContext.WorkerId"]="$(get_octopusvariable "Octopus.Action[Run a Script].Output[isaac wsl].Octopus.Action.ExecutionContext.WorkerId")" ["Octopus.Action[Run a Script].Output[isaac wsl].Octopus.Action.ExecutionContext.IsDynamicWorker"]="$(get_octopusvariable "Octopus.Action[Run a Script].Output[isaac wsl].Octopus.Action.ExecutionContext.IsDynamicWorker")" ["Octopus.Action[Run a Script].AutoRetry.CurrentCount"]="$(get_octopusvariable "Octopus.Action[Run a Script].AutoRetry.CurrentCount")" ["Octopus.Tentacle.CurrentDeployment.TargetedRoles"]="$(get_octopusvariable "Octopus.Tentacle.CurrentDeployment.TargetedRoles")" ["Octopus.Action.Script.CSharp.UseOctopusClassBootstrapper"]="$(get_octopusvariable "Octopus.Action.Script.CSharp.UseOctopusClassBootstrapper")" ["Octopus.Action.Script.CSharp.UseDotnetScript"]="$(get_octopusvariable "Octopus.Action.Script.CSharp.UseDotnetScript")" ["env:LICENSE"]="$(get_octopusvariable "env:LICENSE")" ["env:COMPUTERNAME"]="$(get_octopusvariable "env:COMPUTERNAME")" ["env:PROCESSOR_LEVEL"]="$(get_octopusvariable "env:PROCESSOR_LEVEL")" ["env:USERDOMAIN"]="$(get_octopusvariable "env:USERDOMAIN")" ["env:TEAMCITY_AGENT_OPTS"]="$(get_octopusvariable "env:TEAMCITY_AGENT_OPTS")" ["env:PROCESSOR_REVISION"]="$(get_octopusvariable "env:PROCESSOR_REVISION")" ["env:octopus_api_key"]="$(get_octopusvariable "env:octopus_api_key")" ["env:OneDriveConsumer"]="$(get_octopusvariable "env:OneDriveConsumer")" ["env:Azure_OctopusAPITester_ClientId"]="$(get_octopusvariable "env:Azure_OctopusAPITester_ClientId")" ["env:Google_Map_ApiKey_NotSecret"]="$(get_octopusvariable "env:Google_Map_ApiKey_NotSecret")" ["env:AWS_SECRET_ACCESS_KEY"]="$(get_octopusvariable "env:AWS_SECRET_ACCESS_KEY")" ["env:PATHEXT"]="$(get_octopusvariable "env:PATHEXT")" ["env:SQL_IntegrationTest_Pooling"]="$(get_octopusvariable "env:SQL_IntegrationTest_Pooling")" ["env:Nautilus_Ca_Cert"]="$(get_octopusvariable "env:Nautilus_Ca_Cert")" ["env:GitHub_OctopusAPITester_Password"]="$(get_octopusvariable "env:GitHub_OctopusAPITester_Password")" ["env:TeamCity_OctopusAPITester_AccessToken"]="$(get_octopusvariable "env:TeamCity_OctopusAPITester_AccessToken")" ["env:ChocolateyLastPathUpdate"]="$(get_octopusvariable "env:ChocolateyLastPathUpdate")" ["env:K8S_OctopusAPITester_Server"]="$(get_octopusvariable "env:K8S_OctopusAPITester_Server")" ["env:HOMEPATH"]="$(get_octopusvariable "env:HOMEPATH")" ["env:ALLUSERSPROFILE"]="$(get_octopusvariable "env:ALLUSERSPROFILE")" ["env:PROCESSOR_ARCHITECTURE"]="$(get_octopusvariable "env:PROCESSOR_ARCHITECTURE")" ["env:VAULT_ADDR"]="$(get_octopusvariable "env:VAULT_ADDR")" ["env:ProgramData"]="$(get_octopusvariable "env:ProgramData")" ["env:WSLENV"]="$(get_octopusvariable "env:WSLENV")" ["env:LOGONSERVER"]="$(get_octopusvariable "env:LOGONSERVER")" ["env:SQL_IntegrationTest_Password"]="$(get_octopusvariable "env:SQL_IntegrationTest_Password")" ["env:ProgramFiles(x86)"]="$(get_octopusvariable "env:ProgramFiles(x86)")" ["env:JAVA_HOME"]="$(get_octopusvariable "env:JAVA_HOME")" ["env:NUMBER_OF_PROCESSORS"]="$(get_octopusvariable "env:NUMBER_OF_PROCESSORS")" ["env:Octopus_E2E_Tests_SSH_Targets_Service_Account_Token"]="$(get_octopusvariable "env:Octopus_E2E_Tests_SSH_Targets_Service_Account_Token")" ["env:OPENSSL_CONF"]="$(get_octopusvariable "env:OPENSSL_CONF")" ["env:NVM_HOME"]="$(get_octopusvariable "env:NVM_HOME")" ["env:WT_SESSION"]="$(get_octopusvariable "env:WT_SESSION")" ["env:K8S_OctopusAPITester_Username"]="$(get_octopusvariable "env:K8S_OctopusAPITester_Username")" ["env:OctopusCalamariWorkingDirectory"]="$(get_octopusvariable "env:OctopusCalamariWorkingDirectory")" ["env:Octopus_E2E_Local_Testing_Service_Account_Token"]="$(get_octopusvariable "env:Octopus_E2E_Local_Testing_Service_Account_Token")" ["env:OCTOPUS_UNLIMITED_LICENSE"]="$(get_octopusvariable "env:OCTOPUS_UNLIMITED_LICENSE")" ["env:ComSpec"]="$(get_octopusvariable "env:ComSpec")" ["env:K8S_OctopusAPITester_Password"]="$(get_octopusvariable "env:K8S_OctopusAPITester_Password")" ["env:MyLocalPassword"]="$(get_octopusvariable "env:MyLocalPassword")" ["env:USERDOMAIN_ROAMINGPROFILE"]="$(get_octopusvariable "env:USERDOMAIN_ROAMINGPROFILE")" ["env:CommonProgramW6432"]="$(get_octopusvariable "env:CommonProgramW6432")" ["env:TF_ACC"]="$(get_octopusvariable "env:TF_ACC")" ["env:MyTestVariable"]="$(get_octopusvariable "env:MyTestVariable")" ["env:TF_ACC_LOCAL"]="$(get_octopusvariable "env:TF_ACC_LOCAL")" ["env:Azure_OctopusAPITester_Password"]="$(get_octopusvariable "env:Azure_OctopusAPITester_Password")" ["env:LOCALAPPDATA"]="$(get_octopusvariable "env:LOCALAPPDATA")" ["env:octopusURL"]="$(get_octopusvariable "env:octopusURL")" ["env:PUBLIC"]="$(get_octopusvariable "env:PUBLIC")" ["env:SystemDrive"]="$(get_octopusvariable "env:SystemDrive")" ["env:Nautilus_Api_Address_Prod"]="$(get_octopusvariable "env:Nautilus_Api_Address_Prod")" ["env:ProgramFiles"]="$(get_octopusvariable "env:ProgramFiles")" ["env:GRADLE_HOME"]="$(get_octopusvariable "env:GRADLE_HOME")" ["env:ZES_ENABLE_SYSMAN"]="$(get_octopusvariable "env:ZES_ENABLE_SYSMAN")" ["env:ProgramW6432"]="$(get_octopusvariable "env:ProgramW6432")" ["env:Azure_OctopusAPITester_TenantId"]="$(get_octopusvariable "env:Azure_OctopusAPITester_TenantId")" ["env:KUBECONFIG"]="$(get_octopusvariable "env:KUBECONFIG")" ["env:TF_LOG"]="$(get_octopusvariable "env:TF_LOG")" ["env:NVM_SYMLINK"]="$(get_octopusvariable "env:NVM_SYMLINK")" ["env:TEAMCITY_SERVER_OPTS"]="$(get_octopusvariable "env:TEAMCITY_SERVER_OPTS")" ["env:SESSIONNAME"]="$(get_octopusvariable "env:SESSIONNAME")" ["env:AZURE_SUBSCRIPTION_ID"]="$(get_octopusvariable "env:AZURE_SUBSCRIPTION_ID")" ["env:POWERSHELL_DISTRIBUTION_CHANNEL"]="$(get_octopusvariable "env:POWERSHELL_DISTRIBUTION_CHANNEL")" ["env:WIX"]="$(get_octopusvariable "env:WIX")" ["env:AZURE_TENANT_ID"]="$(get_octopusvariable "env:AZURE_TENANT_ID")" ["env:Google_Places_API_Key"]="$(get_octopusvariable "env:Google_Places_API_Key")" ["env:VAULT_TOKEN"]="$(get_octopusvariable "env:VAULT_TOKEN")" ["env:AWS_ACCESS_KEY_ID"]="$(get_octopusvariable "env:AWS_ACCESS_KEY_ID")" ["env:Path"]="$(get_octopusvariable "env:Path")" ["env:TMP"]="$(get_octopusvariable "env:TMP")" ["env:VAULT_NAMESPACE"]="$(get_octopusvariable "env:VAULT_NAMESPACE")" ["env:SQL_IntegrationTest_Username"]="$(get_octopusvariable "env:SQL_IntegrationTest_Username")" ["env:K8S_OctopusAPITester_Token"]="$(get_octopusvariable "env:K8S_OctopusAPITester_Token")" ["env:OCTOPUS_URL"]="$(get_octopusvariable "env:OCTOPUS_URL")" ["env:AWS_E2E_SecretKeyId"]="$(get_octopusvariable "env:AWS_E2E_SecretKeyId")" ["env:GOPATH"]="$(get_octopusvariable "env:GOPATH")" ["env:Octopus.Action.Script.CSharp.UseDotnetScript"]="$(get_octopusvariable "env:Octopus.Action.Script.CSharp.UseDotnetScript")" ["env:USERPROFILE"]="$(get_octopusvariable "env:USERPROFILE")" ["env:AWS_OctopusAPITester_Access"]="$(get_octopusvariable "env:AWS_OctopusAPITester_Access")" ["env:OneDrive"]="$(get_octopusvariable "env:OneDrive")" ["env:WT_PROFILE_ID"]="$(get_octopusvariable "env:WT_PROFILE_ID")" ["env:AWS_OctopusAPITester_Secret"]="$(get_octopusvariable "env:AWS_OctopusAPITester_Secret")" ["env:AZURE_CLIENT_PASSWORD"]="$(get_octopusvariable "env:AZURE_CLIENT_PASSWORD")" ["env:ChocolateyToolsLocation"]="$(get_octopusvariable "env:ChocolateyToolsLocation")" ["env:HOMEDRIVE"]="$(get_octopusvariable "env:HOMEDRIVE")" ["env:SystemRoot"]="$(get_octopusvariable "env:SystemRoot")" ["env:AWS_E2E_AccessKeyId"]="$(get_octopusvariable "env:AWS_E2E_AccessKeyId")" ["env:APPDATA"]="$(get_octopusvariable "env:APPDATA")" ["env:PROCESSOR_IDENTIFIER"]="$(get_octopusvariable "env:PROCESSOR_IDENTIFIER")" ["env:PNPM_HOME"]="$(get_octopusvariable "env:PNPM_HOME")" ["env:DriverData"]="$(get_octopusvariable "env:DriverData")" ["env:windir"]="$(get_octopusvariable "env:windir")" ["env:PSModulePath"]="$(get_octopusvariable "env:PSModulePath")" ["env:AZURE_CLIENT_ID"]="$(get_octopusvariable "env:AZURE_CLIENT_ID")" ["env:OS"]="$(get_octopusvariable "env:OS")" ["env:Azure_OctopusAPITester_SubscriptionId"]="$(get_octopusvariable "env:Azure_OctopusAPITester_SubscriptionId")" ["env:OCTODISABLEOCTOCONTAINERLOGGING"]="$(get_octopusvariable "env:OCTODISABLEOCTOCONTAINERLOGGING")" ["env:azure_client_secret"]="$(get_octopusvariable "env:azure_client_secret")" ["env:OCTOPUS_APIKEY"]="$(get_octopusvariable "env:OCTOPUS_APIKEY")" ["env:TEMP"]="$(get_octopusvariable "env:TEMP")" ["env:GitHub_OctopusAPITester_Username"]="$(get_octopusvariable "env:GitHub_OctopusAPITester_Username")" ["env:USERNAME"]="$(get_octopusvariable "env:USERNAME")" ["env:CommonProgramFiles"]="$(get_octopusvariable "env:CommonProgramFiles")" ["env:SQL_IntegrationTest_Instance"]="$(get_octopusvariable "env:SQL_IntegrationTest_Instance")" ["env:CommonProgramFiles(x86)"]="$(get_octopusvariable "env:CommonProgramFiles(x86)")" ["Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath"]="$(get_octopusvariable "Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath")" ["Octopus.Tentacle.PreviousInstallation.CustomInstallationDirectory"]="$(get_octopusvariable "Octopus.Tentacle.PreviousInstallation.CustomInstallationDirectory")" ["Octopus.Tentacle.PreviousInstallation.PackageFilePath"]="$(get_octopusvariable "Octopus.Tentacle.PreviousInstallation.PackageFilePath")" ["Octopus.Tentacle.PreviousInstallation.PackageVersion"]="$(get_octopusvariable "Octopus.Tentacle.PreviousInstallation.PackageVersion")" ["Octopus.Tentacle.PreviousSuccessfulInstallation.OriginalInstalledPath"]="$(get_octopusvariable "Octopus.Tentacle.PreviousSuccessfulInstallation.OriginalInstalledPath")" ["Octopus.Tentacle.PreviousSuccessfulInstallation.CustomInstallationDirectory"]="$(get_octopusvariable "Octopus.Tentacle.PreviousSuccessfulInstallation.CustomInstallationDirectory")" ["Octopus.Tentacle.PreviousSuccessfulInstallation.PackageFilePath"]="$(get_octopusvariable "Octopus.Tentacle.PreviousSuccessfulInstallation.PackageFilePath")" ["Octopus.Tentacle.PreviousSuccessfulInstallation.PackageVersion"]="$(get_octopusvariable "Octopus.Tentacle.PreviousSuccessfulInstallation.PackageVersion")" ["Octopus.Action.Script.ScriptFileName"]="$(get_octopusvariable "Octopus.Action.Script.ScriptFileName")")
    else
      echo "Bash version 4.2 or later is required to use octopus_parameters"
    fi
fi

return $"[\"{variable.Name.Replace("\"", "\\\"")}\"]=\"{variableValue}\"";
});
}

static IList<EncryptedVariable> EncryptVariables(IVariables variables)
{
return variables.GetNames()
Expand Down
13 changes: 12 additions & 1 deletion source/Calamari.Common/Features/Scripting/Bash/Bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,15 @@ function log_environment_information
echo "##octopus[stdout-default]"
}

log_environment_information
log_environment_information

bashParametersArrayFeatureToggle=#### BashParametersArrayFeatureToggle ####

if [ "$bashParametersArrayFeatureToggle" = true ]; then
if (( ${BASH_VERSINFO[0]} > 4 || (${BASH_VERSINFO[0]} == 4 && ${BASH_VERSINFO[1]} > 2) )); then
declare -grA octopus_parameters=(#### VariableNamesArrayDeclarations ####)
else
echo "Bash version 4.2 or later is required to use octopus_parameters"
fi
fi

Loading