This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Encode-ServiceMessageValue([string]$value) | |
{ | |
$valueBytes = [System.Text.Encoding]::UTF8.GetBytes($value) | |
return [Convert]::ToBase64String($valueBytes) | |
} | |
function Set-OctopusVariable([string]$name, [string]$value) | |
{ | |
$name = Encode-ServiceMessageValue($name) | |
$value = Encode-ServiceMessageValue($value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Easiest way to get these dlls is to find them | |
#on the tentacle/Octopus install dir like i'm doing here | |
Add-Type -Path "C:\Program Files\Octopus Deploy\Tentacle\Newtonsoft.Json.dll" | |
Add-Type -Path "C:\Program Files\Octopus Deploy\Tentacle\Octopus.Client.dll" | |
Add-Type -Path "C:\Program Files\Octopus Deploy\Tentacle\Octopus.Platform.dll" | |
$OctopusURL = "" #eg "http://BestDeploymentTool.mycompany.com" | |
$APIKey = "" #eg "API-YHMOPNVMRLFXJBV4EQRDIDNDJ" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$apiKey = "" #Octopus API Key | |
$OctopusURL = "" #Octopus URL | |
$Header = @{ "X-Octopus-ApiKey" = $apiKey } | |
$ProjectName = "" #project name | |
$EnvironmentName = "" #environment name | |
[string[]]$filter = "" #Pattern to filter machines. e.g. "*:10934","*db*","http://Webserver1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Id": "ActionTemplates-67", | |
"Name": "IIS Application - Create", | |
"Description": "Create an IIS virtual application (a virtual directory with an application pool)", | |
"ActionType": "Octopus.Script", | |
"Version": 2, | |
"Properties": { | |
"Octopus.Action.Script.ScriptBody": "## --------------------------------------------------------------------------------------\r\n## Input\r\n## --------------------------------------------------------------------------------------\r\n\r\n$virtualPath = $OctopusParameters['VirtualPath']\r\n$physicalPath = $OctopusParameters['PhysicalPath']\r\n$applicationPoolName = $OctopusParameters['ApplicationPoolName']\r\n$parentSite = $OctopusParameters['ParentSite']\r\n\r\n## --------------------------------------------------------------------------------------\r\n## Helpers\r\n## --------------------------------------------------------------------------------------\r\n# Helper for validating input parameters\r\nfunction Validate-Parameter([string]$foo, [string[]]$validInput, $para |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Config | |
$OctopusURL = "" #Octopus URL | |
$APIKey = "" #Octopus APIKey | |
$projectname = "" #Name of the project | |
$Name = "" #Name of the variable | |
$Value = "" #Value of the variable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Id": "ActionTemplates-129", | |
"Name": "IIS Virtual Directory - Create", | |
"Description": "Create an IIS virtual directory.", | |
"ActionType": "Octopus.Script", | |
"Version": 2, | |
"Properties": { | |
"Octopus.Action.Script.ScriptBody": "## --------------------------------------------------------------------------------------\n## Input\n## --------------------------------------------------------------------------------------\n\n$virtualPath = $OctopusParameters['VirtualDirectoryVirtualPath']\n$physicalPath = $OctopusParameters['PhysicalPath']\n$parentSite = $OctopusParameters['ParentSite']\n\n## --------------------------------------------------------------------------------------\n## Helpers\n## --------------------------------------------------------------------------------------\n# Helper for validating input parameters\nfunction Validate-Parameter([string]$foo, [string[]]$validInput, $parameterName) {\n Write-Host \"${parameterName}: $foo\"\n if (! $foo) {\n throw \"No value was set for $par |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Configuration. All variables inside this section are mandatory. | |
$octopus_url = "http://localhost" | |
$octopus_apikey = "API-YHMOPNVMRLFXJBV4EQWWFKXAWLQ" | |
$header = @{"X-Octopus-ApiKey"="$octopus_apikey"} | |
$OctoExePath = "C:\Tools\Octo.exe" | |
$EnvironmentName = "MyEnvironmentName" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Config | |
$apiKey = "YourAPIKey" #eg API-YHJACKVMRLFXBAUEREQWWFKXALQ | |
$octopusURL = "YourOctopusURL" | |
$environmentName = "YourEnvironmentName" | |
$header = @{ "X-Octopus-ApiKey" = $apiKey } | |
##Process | |
$environments = Invoke-RestMethod "$OctopusURL/api/Environments/all" -Method get -Headers $header | ?{$_.name -eq "$environmentName"} | |
$machines = (Invoke-RestMethod "$OctopusURL$($environment.links.Machines)" -Method Get -Headers $header).items |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$apiKey = "Your API Key" | |
$OctopusURL = "Your Octopus URL" | |
$Header = @{ "X-Octopus-ApiKey" = $apiKey } | |
$ProjectName = "Your Project Name" | |
#Getting Environment and Project By Name | |
$Project = Invoke-WebRequest -Uri "$OctopusURL/api/projects/$ProjectName" -Headers $Header| ConvertFrom-Json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$apiKey = "Your API Key" | |
$OctopusURL = "Your Octopus URL" | |
$Header = @{ "X-Octopus-ApiKey" = $apiKey } | |
$ProjectName = "Your project name" | |
$EnvironmentName = "Your environment name" | |
#Getting Environment and Project By Name | |
$Project = Invoke-WebRequest -Uri "$OctopusURL/api/projects/$ProjectName" -Headers $Header| ConvertFrom-Json |