Quantcast
Viewing latest article 8
Browse Latest Browse All 19

Octopus C# Step Templates

Nuget Packages

If you want to create larger step templates for Octopus it is advisable to use C# scripts which come from a nuget package.

  • nuget packages can store dependency DLLs as well as the actual script, allowing you to use third part DLLs and not just those stored in the GAC.
#r "Newtonsoft.Json.dll"
  • separate the script into a number of files, e.g.
#load "pool.csx"

Scripting

Scripting in C# with Octopus does not work well namespaces or using statements so it’s advisable to qualify the types with their full name instead.

private System.Net.NetworkCredential _devAdminCredentials = new System.Net.NetworkCredential("admin", "Password123");

Octopus Parameters

Parameters for the step are created via the UI and can be referenced in C#.

Octopus.Parameters["websitePool"]

It is a good idea to export the step template to JSON so that you have a backup of all the parameters which should be stored in source control.


Viewing latest article 8
Browse Latest Browse All 19

Trending Articles