Skip to content

Instantly share code, notes, and snippets.

View Dalmirog-zz's full-sized avatar

Dalmiro Granas Dalmirog-zz

View GitHub Profile
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)
@Dalmirog-zz
Dalmirog-zz / UpdateOctopusVariables.ps1
Last active August 29, 2015 14:16
UpdateOctopusVariables
#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"
@Dalmirog-zz
Dalmirog-zz / file.ps1
Created March 5, 2015 07:17
New Release for specific machines
$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"
@Dalmirog-zz
Dalmirog-zz / file.json
Created March 6, 2015 22:03
tweaked step template to create web app
{
"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
@Dalmirog-zz
Dalmirog-zz / CreateOctopusVariable.ps1
Last active May 26, 2016 09:32
Create and Octopus Project Variable
#Config
$OctopusURL = "" #Octopus URL
$APIKey = "" #Octopus APIKey
$projectname = "" #Name of the project
$Name = "" #Name of the variable
$Value = "" #Value of the variable
@Dalmirog-zz
Dalmirog-zz / script
Created March 25, 2015 21:50
Updated Octopus Step template to create IIS virtual directory
{
"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
@Dalmirog-zz
Dalmirog-zz / File.ps1
Last active August 29, 2015 14:18
Deploy last release of specific Project/Environment to a set a machines
#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"
@Dalmirog-zz
Dalmirog-zz / GetRandomTentacle.ps1
Created April 6, 2015 14:12
Get random tentacle from environment
##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
@Dalmirog-zz
Dalmirog-zz / file.ps1
Created April 10, 2015 13:45
Get next Octopus release version
$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
@Dalmirog-zz
Dalmirog-zz / DeleteDeployments.ps1
Last active August 16, 2016 20:06
Delete all deploments for a Project-Environment
$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