PowerShell script language raising exception at the release deploy

Hi

I’m testing Octopus Deploy using the Docker image.

When I choose PowerShell script language in my process step configuration, I run into a segmentation fault in the release deploy.

Task ID:        ServerTasks-103
Related IDs:    Deployments-22, Channels-1, Releases-22, Projects-1, Spaces-1, Environments-1
Task status:    Failed
Task queued:    Wednesday, 02 December 2020 3:05:51 PM +00:00
Task started:   Wednesday, 02 December 2020 3:05:51 PM +00:00
Task completed: Wednesday, 02 December 2020 3:05:52 PM +00:00
Task duration:  1 second
Server version: 2020.3.1+Branch.tags-2020.3.1.Sha.a296493e8077af329c4e8f884a5e7759842c6954
Server node:    d4484cb32549

                    | == Failed: Deploy Hello, world release 2020.12.10 to Dev ==
15:05:51   Verbose  |   Guided failure is not enabled for this task
15:05:52   Fatal    |   The deployment failed because one or more steps failed. Please see the deployment log for details.
                    | 
                    |   == Failed: Step 1: Run My Script ==
15:05:52   Fatal    |     The step failed: Activity Run My Script on the Octopus Server failed with error 'The remote script failed with exit code 255'.
15:05:52   Verbose  |     Run My Script completed
                    |   
                    |     == Failed: Octopus Server ==
15:05:51   Verbose  |       Octopus Server version: 2020.3.1+Branch.tags-2020.3.1.Sha.a296493e8077af329c4e8f884a5e7759842c6954
15:05:51   Verbose  |       Environment Information:
                    |       IsRunningInContainer: True
                    |       OperatingSystem: Linux 5.4.39-linuxkit #1 SMP Fri May 8 23:03:06 UTC 2020
                    |       OsBitVersion: x64
                    |       Is64BitProcess: True
                    |       CurrentUser: root
                    |       MachineName: d4484cb32549
                    |       ProcessorCount: 8
                    |       CurrentDirectory: /Octopus
                    |       TempDirectory: /tmp/
                    |       HostProcessName: Octopus.Server
                    |       PID: 1
15:05:51   Verbose  |       Executing Run My Script (type Run a Script) on Octopus Server
15:05:51   Verbose  |       Using Calamari.netfx 13.0.10
15:05:51   Verbose  |       Using Calamari.linux-x64 13.0.10
15:05:51   Verbose  |       Running this script in the Octopus Server security context (root)
15:05:51   Verbose  |       Starting /bin/bash in working directory '/home/octopus/.octopus/OctopusServer/Server/Work/20201202150551-103-2' using 'Unicode (UTF-8)' encoding running as 'root' with the same environment variables as the launching process
15:05:51   Verbose  |       Calamari Version: 13.0.10
15:05:51   Verbose  |       Environment Information:
15:05:51   Verbose  |       OperatingSystem: Unix 5.4.39.0
15:05:51   Verbose  |       OsBitVersion: x64
15:05:51   Verbose  |       Is64BitProcess: True
15:05:51   Verbose  |       Running on Mono: False
15:05:51   Verbose  |       CurrentUser: root
15:05:51   Verbose  |       MachineName: d4484cb32549
15:05:51   Verbose  |       ProcessorCount: 8
15:05:51   Verbose  |       CurrentDirectory: /home/octopus/.octopus/OctopusServer/Server/Work/20201202150551-103-2
15:05:51   Verbose  |       TempDirectory: /tmp/
15:05:51   Verbose  |       HostProcess: Calamari (405)
15:05:51   Verbose  |       Unable to get the system proxy settings due to not running under .Net Framework. Calamari will not use any proxy settings.
15:05:52   Verbose  |       Performing variable substitution on '/home/octopus/.octopus/OctopusServer/Server/Work/20201202150551-103-2/Script.ps1'
15:05:52   Verbose  |       Executing '/home/octopus/.octopus/OctopusServer/Server/Work/20201202150551-103-2/Script.ps1'
15:05:52   Verbose  |       Setting Proxy Environment Variables
15:05:52   Verbose  |       Unable to get the system proxy settings due to not running under .Net Framework. Calamari will not use any proxy settings.
15:05:52   Error    |       Unable to execute pwsh, please ensure that pwsh is installed and is in the PATH.
15:05:52   Error    |       System.Exception: Error when attempting to execute pwsh: No such file or directory
15:05:52   Error    |       ---> System.ComponentModel.Win32Exception (2): No such file or directory
15:05:52   Error    |       at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
15:05:52   Error    |       at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
15:05:52   Error    |       at System.Diagnostics.Process.Start()
15:05:52   Error    |       at Calamari.Integration.Processes.SilentProcessRunner.ExecuteCommand(String executable, String arguments, String workingDirectory, Dictionary`2 environmentVars, String userName, SecureString password, Action`1 output, Action`1 error) in C:\buildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Features\Processes\SilentProcessRunner.cs:line 149
15:05:52   Error    |       --- End of inner exception stack trace ---
15:05:52   Error    |       at Calamari.Integration.Processes.SilentProcessRunner.ExecuteCommand(String executable, String arguments, String workingDirectory, Dictionary`2 environmentVars, String userName, SecureString password, Action`1 output, Action`1 error) in C:\buildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Features\Processes\SilentProcessRunner.cs:line 162
15:05:52   Error    |       at Calamari.Integration.Processes.CommandLineRunner.Execute(CommandLineInvocation invocation) in C:\buildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Features\Processes\CommandLineRunner.cs:line 25
15:05:52   Error    |       The command that caused the exception was: "pwsh" -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command "Set-PSDebug -Trace 0;Try {. {. '/home/octopus/.octopus/OctopusServer/Server/Work/20201202150551-103-2/Bootstrap.Script.ps1' -OctopusKey 'NYDcnPgQT2vc2bL4dSkYww=='; if ((test-path variable:global:lastexitcode)) { exit $LastExitCode }};} catch { throw }"
15:05:52   Verbose  |       Process /bin/bash in /home/octopus/.octopus/OctopusServer/Server/Work/20201202150551-103-2 exited with code 255
15:05:52   Verbose  |       Updating manifest with output variables
15:05:52   Verbose  |       Updating manifest with action evaluated variables
15:05:52   Fatal    |       The remote script failed with exit code 255
15:05:52   Fatal    |       The action Run My Script on the Octopus Server failed

I don’t have any issue using bah. Please can you check at your side?

Regards,
Eugène NV

Hi Eugène,

Thanks for getting in touch! I’m sorry to hear about this unexpected issue you’re hitting. It looks like a case of pwsh not being installed in the container. Digging a little bit, it looks like we only just recently added pwsh by default to our Linux images, so using the latest should have pwsh included and fix this issue up for you.

Let me know how you go or if you have any other questions or concerns!

Best regards,

Kenny

Hi Kenny,

Thank you for your answer, please where and how can I get the latest image?

Also, even for Bash script language which works, it seems like variables reference does not work in process steps; For example this statement picked from the tutorial does not display the expected value to the output :

echo $OctopusParameters[“Helloworld.Greeting”]

Instead, it displays the string "Helloworld.Greeting"

Thanks again for your help.

Eugène NG

Hi Eugène,

Thanks for following up! Each image can be found at the following docker hub link.

It looks like you’re using the PowerShell syntax to retrieve the project variable, where in Bash the equivalent looks like $(get_octopusvariable "Helloworld.Greeting"). Does echoing this in your Bash script work as expected?

I hope this helps, and let me know how you go!

Best regards,

Kenny

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.