Slide 1
Excellent Education Program
Innovative Methods of Teaching

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cum sociis natoque penatibus et magnis dis parturient.

Slide 2
Learning Through Play
Devoted to the Early Education

Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

Slide 2
Learning Through Play
Devoted to the Early Education

Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

Slide 2
Learning Through Play
Devoted to the Early Education

Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

Slide 2
Learning Through Play
Devoted to the Early Education

Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

Slide 3
Learning Through Play
Find a Class for your Children

Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis.

previous arrow
next arrow

Octopus Deploy – How to handle deployment errors and script failure response.

Spread the Knowledge

Each of your scripts will be bootstrapped by the open-source Calamari project to provide access to variables and helper functions. You can see how your scripts are bootstrapped in the Calamari source code.

https://github.com/OctopusDeploy/Calamari

https://github.com/OctopusDeploy/Calamari/blob/master/source/Calamari.Shared/Integration/Scripting

Octopus Deploy supports the following scripts:

PowerShell scripts (.ps1)
C# scripts (.csx) using ScriptCS
Bash scripts (.sh)
F# scripts (.fsx)
Python scripts (.py)

When Calamari executes your scripts, it does so within the context of the working directory by default: C:\Octopus\Work\

Calamari examines the exit code of the script engine to determine whether the script failed. If the exit code is zero, Calamari assumes the script ran successfully. If the exit code is non-zero, then Calamari assumes the script failed.

Syntax errors and unhandled exceptions will result in a non-zero exit code from the script engine, which will fail the deployment

Error Handling in PowerShell Scripts – For PowerShell scripts Calamari also sets the $ErrorActionPreference to Stop before invoking your script. This means that if a command fails, the rest of the script won’t be executed. At the end of the script, Calamari also checks $LastExitCode to see if the last Windows-based program that you invoked exited successfully.

Note that you’ll need to check $LastExitCode yourself if you run multiple Windows programs. For example, with this script, Calamari would correctly see that ping returned an exit code of 1 (the host couldn’t be contacted) and will assume the script failed:

  • https://octopus.com/docs/deployment-examples/custom-scripts/error-handling
  • https://octopus.com/docs/deployment-examples/custom-scripts
  • https://octopus.com/docs/deployment-examples/custom-scripts/debugging-powershell-scripts
Rajesh Kumar
Latest posts by Rajesh Kumar (see all)