Skip to content

Commit

Permalink
Updating Dotnet Script tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacCalligeros95 committed Oct 10, 2023
1 parent a5959dc commit 270efe1
Show file tree
Hide file tree
Showing 86 changed files with 100 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ Write-Error "This will be logged as an Error and may cause your script to stop r
Console.WriteLine("This will be logged as Information");
Console.Out.WriteLine("This will be logged as Information too!");
Console.Error.WriteLine("This will be logged as an Error.");
Octopus.WriteVerbose("Verbose!!!");
Octopus.WriteHighlight("This is a highlight");
Octopus.WriteWait("Deployment is waiting on something");
Octopus.WriteWarning("Warning");
WriteVerbose("Verbose!!!");
WriteHighlight("This is a highlight");
WriteWait("Deployment is waiting on something");
WriteWarning("Warning");
```

</details>
Expand Down Expand Up @@ -106,8 +106,8 @@ Update-Progress 50 "Woah, we're halfway there!"
<summary>C#</summary>

```csharp
Octopus.UpdateProgress(10);
Octopus.UpdateProgress(50, "Woah, we're halfway there!");
UpdateProgress(10);
UpdateProgress(50, "Woah, we're halfway there!");
```

</details>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/docs/deployments/custom-scripts/output-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Set-OctopusVariable -name "AppInstanceName" -value "MyAppInstance"
<summary>C#</summary>

```csharp
Octopus.SetVariable("AppInstanceName", "MyAppInstance");
SetVariable("AppInstanceName", "MyAppInstance");
```

</details>
Expand Down Expand Up @@ -74,7 +74,7 @@ $appInstanceName = $OctopusParameters["Octopus.Action[Determine App Instance Nam
<summary>C#</summary>

```csharp
var appInstanceName = Octopus.Parameters["Octopus.Action[Determine App Instance Name].Output.AppInstanceName"]
var appInstanceName = OctopusParameters["Octopus.Action[Determine App Instance Name].Output.AppInstanceName"]
```

</details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Write-Host "$Environment storage path: $StoragePath"

## Passing parameters to C# scripts {#Customscripts-PassingparameterstoC#scripts}

You can pass parameters to C# scripts [as described here for the ScriptCS engine](https://github.com/scriptcs/scriptcs/wiki/Pass-arguments-to-scripts). ScriptCS only supports positional parameters.
You can pass parameters to C# scripts [as described here for the dotnet-script engine](https://github.com/dotnet-script/dotnet-script#passing-arguments-to-scripts).

**Script Parameters in Octopus**

Expand All @@ -79,8 +79,8 @@ You can pass parameters to C# scripts [as described here for the ScriptCS engine
**Usage in C# script**

```csharp
var environment = Env.ScriptArgs[0]
var storagePath = Env.ScriptArgs[1]
var environment = Args[0]
var storagePath = Args[1]
Console.WriteLine("{0} storage path: {1}", environment, storagePath);
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ Get-Content ".\subfolder\file.txt"

```csharp C#
// in pre-deploy, in post-deploy if custom installation directory has not been defined
var extractPath = Octopus.Parameters["Octopus.Action.Package.InstallationDirectoryPath"];
var extractPath = OctopusParameters["Octopus.Action.Package.InstallationDirectoryPath"];
// if a custom installation directory has been defined
var customPath = Octopus.Parameters["Octopus.Action.Package.CustomInstallationDirectory"];
var customPath = OctopusParameters["Octopus.Action.Package.CustomInstallationDirectory"];
// original extract path,
Console.WriteLine(File.ReadAllText(extractPath + @"\subfolder\file.txt"));
// or when a custom installation directory has been defined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Write-Host "Connection string is: $connectionString"

```csharp
// It's a good idea to copy the value into a local variable to avoid quoting issues
var connectionString = Octopus.Parameters["MyApp.ConnectionString"];
var connectionString = OctopusParameters["MyApp.ConnectionString"];
Console.WriteLine("MyApp.ConnectionString: " + connectionString);
```

Expand Down
4 changes: 2 additions & 2 deletions src/pages/docs/projects/deployment-process/artifacts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ New-OctopusArtifact -Path "C:\Windows\System32\drivers\etc\hosts" -Name "$([Syst

```csharp
// Collect a custom log file from the current working directory using the file name as the name of the artifact
Octopus.CreateArtifact("output.log");
CreateArtifact("output.log");

// Collect the hosts file but using a custom name for each machine so you can differentiate between them
// Note: to collect this artifact would require the Tentacle process to be elevated as a high privileged user account
Octopus.CreateArtifact(@"C:\Windows\System32\drivers\etc\hosts", System.Environment.MachineName + "-hosts.txt");
CreateArtifact(@"C:\Windows\System32\drivers\etc\hosts", System.Environment.MachineName + "-hosts.txt");
```

</details>
Expand Down
10 changes: 5 additions & 5 deletions src/pages/docs/projects/variables/output-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Set-OctopusVariable -name "TestResult" -value "Passed"
<summary>C#</summary>

```csharp
Octopus.SetVariable("TestResult", "Passed");
SetVariable("TestResult", "Passed");
```

</details>
Expand Down Expand Up @@ -74,7 +74,7 @@ $TestResult = $OctopusParameters["Octopus.Action[StepA].Output.TestResult"]
<summary>C#</summary>

```csharp
var testResult = Octopus.Parameters["Octopus.Action[StepA].Output.TestResult"]
var testResult = OctopusParameters["Octopus.Action[StepA].Output.TestResult"]
```

</details>
Expand Down Expand Up @@ -117,7 +117,7 @@ Set-OctopusVariable -name "Password" -value "correct horse battery staple" -sens
<summary>C#</summary>

```csharp
Octopus.SetVariable("Password", "correct horse battery staple", true);
SetVariable("Password", "correct horse battery staple", true);
```

</details>
Expand Down Expand Up @@ -216,14 +216,14 @@ Set-OctopusVariable -name "TestResult" -value "Passed"

### C# {#Outputvariables-C#}

[ScriptCS Bootstrapping](https://github.com/OctopusDeploy/Calamari/tree/master/source/Calamari.Common/Features/Scripting/ScriptCS)
[Dotnet Script Bootstrapping](https://github.com/OctopusDeploy/Calamari/tree/master/source/Calamari.Common/Features/Scripting/DotnetScript)

From a C# script, you can use the `public static void SetVariable(string name, string value)` method to set the name and value of an output variable.

**C#**

```csharp
Octopus.SetVariable("TestResult", "Passed");
SetVariable("TestResult", "Passed");
```

### Bash {#Outputvariables-Bash}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ foreach ($environmentName in $environments) {

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function AddAzureLogins
<summary>C#</summary>

```csharp
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ foreach ($environmentName in $environments) {

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ catch
<summary>C#</summary>

```csharp
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ catch
<summary>C#</summary>

```csharp
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ foreach ($tenant in $tenants)
<summary>C#</summary>

```csharp
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"
using Octopus.Client;
using Octopus.Client.Model;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ while ($canContinue -eq $true)

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
2 changes: 1 addition & 1 deletion src/shared-content/scripts/change-feed-scripts.include.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ catch {

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "C:\path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

// Declare working variables
var octopusURL = "https://youroctourl";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ else
<summary>C#</summary>

```csharp
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"
using Octopus.Client;
using Octopus.Client.Model;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ catch {

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ catch {

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ $repositoryForSpace.Runbooks.Modify($runbook)
<summary>C#</summary>

```csharp
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"
using Octopus.Client;
using Octopus.Client.Model;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ catch
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
// Reference Octopus.Client
//#r "path\to\Octopus.Client.dll"
//#r "nuget: Octopus.Client"
using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ $repositoryForSpace.Channels.Create($channel)

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ catch
// It also requires version 11.3.3355 or higher of the Octopus.Client library
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ catch

```csharp
// If using .net Core, be sure to add the NuGet package of System.Security.Permissions
#r "path\to\Octopus.Client.dll"
#r "nuget: Octopus.Client"

using Octopus.Client;
using Octopus.Client.Model;
Expand Down
Loading

0 comments on commit 270efe1

Please sign in to comment.