HOWTO Make C# In-Line Script for Octopus

using System.IO;
// Doesn't the in-line script need to have a using statement to include Octopus?

namespace Fleetcor
{
  public class Deployment
  {
    public int Deploy() // How to make this function get called from an in-line script when the script runs.
    {
      string csWorkFolder = Octopus.Parameters["Work_Folder"]; // Don't we need to add a using statement for the "Octopus"?
      File.ReadAllText(csWorkFolder + "\\web.config");

      // How to return a failure code to have the deployment stop, and preferably denote a
      // full error that is seen EVERYWHERE, that Octpus show any error, first and foremost, as
      // the MOST PROMINENT error for the failure.
      //
      // To clarify, Octopus will show errors on the screen, when a deployment fails. How can we
      // make thart first error, and all other errors, always show the script's error.

      return 0; // Is zero failure?
    }
  }
}

Hi @J-S-B,

Thanks for getting in touch! Sorry for the delay in getting back to you with some information.

It’s worth noting that Octopus uses ScriptCS and not raw C# when writing C# scripts.

The following documentation page has some details on how Octopus uses Script Modules, including C#.

We also have a documentation page on how Octopus handles Error Handling which should be helpful.

If you have any further questions or run into any issues here, please let me know.

Best regards,
Daniel

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