Skip to content

Instantly share code, notes, and snippets.

@PaulStovell
Last active December 15, 2015 02:19
Show Gist options
  • Save PaulStovell/5186220 to your computer and use it in GitHub Desktop.
Save PaulStovell/5186220 to your computer and use it in GitHub Desktop.
How Octopus will invoke ScriptCS scripts.
tentacle run-script -f Hello.csx -v Hello=Bar
// This file is generated
#load "P:\\GitHub\\Octopus\\source\\Octopus.Tentacle\\bin\\Configure.41aa7a71-af29-4e8d-9539-615b498a37a9.csx"
#load "P:\\GitHub\\Octopus\\source\\Octopus.Tentacle\\bin\\Deploy.csx"
// This file is generated
using System;
public static class Octopus
{
public static readonly OctopusParametersDictionary Parameters = new OctopusParametersDictionary();
public class OctopusParametersDictionary : System.Collections.Generic.Dictionary<string,string>
{
public OctopusParametersDictionary() : base(System.StringComparer.OrdinalIgnoreCase)
{
// Variables:
this[System.Text.Encoding.UTF8.GetString(Convert.FromBase64String( "SGVsbG8=" ) )] = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String( "QmFy" ) );
}
public string Hello { get { return this[System.Text.Encoding.UTF8.GetString(Convert.FromBase64String( "SGVsbG8=" ) )]; } }
}
// Functions:
static string EncodeServiceMessageValue(string value)
{
var valueBytes = System.Text.Encoding.UTF8.GetBytes(value);
return Convert.ToBase64String(valueBytes);
}
public static void SetOctopusVariable(string name, string value)
{
name = EncodeServiceMessageValue(name);
value = EncodeServiceMessageValue(value);
Console.WriteLine("##octopus[setVariable name='$name' value='$value']");
}
}
// This is the user's script:
using System;
Console.WriteLine("Hello! " + Octopus.Parameters["Hello"]);
@mastoj
Copy link

mastoj commented Aug 5, 2013

@PaulStovell, am I supposed to be able to call Octopus.SetOctopusVariable(name, value) from my PreDeploy/Deploy? Tentacle crashes when I do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment