Skip to content

Instantly share code, notes, and snippets.

View Damovisa's full-sized avatar
🏠
Home!

Damian Brady Damovisa

🏠
Home!
View GitHub Profile
@Damovisa
Damovisa / WriteAllStepDetails
Last active August 29, 2015 14:16
Octopus Powershell script to write a bunch of details for every step in the process
$i = 0
$step = $OctopusParameters["Octopus.Step[$i].Id"]
while ($step -ne $null) {
Write-Output $OctopusParameters["Octopus.Step[$i].Id"]
Write-Output $OctopusParameters["Octopus.Step[$i].Name"]
Write-Output $OctopusParameters["Octopus.Step[$i].TargetRoles"]
Write-Output $OctopusParameters["Octopus.Step[$i].Script.ScriptBody"]
$i++
$step = $OctopusParameters["Octopus.Step[$i].Id"]
@Damovisa
Damovisa / gist:db8bdeee993bd15639f0
Last active August 29, 2015 14:18
Octopus Deploy Raven Import Script
# Raven Import Script
# You'll need a copy of Raven.Abstractions.dll, Raven.Client.Lightweight.dll, Jint.Raven.dll and Raven.Smuggler.exe
# in a lib folder (note: one more than the export script) under the location of this script.
# You can find them in the folder where Octopus Deploy is installed.
[CmdletBinding()]
Param(
[Parameter(Mandatory=$false,Position=1)]
[string]$importPath = ".\dump.raven",
@Damovisa
Damovisa / gist:34ef3a589a63f687281e
Last active December 16, 2015 23:57
Octopus Deploy Raven Export Script
# Raven Export Script
# You'll need a copy of Raven.Abstractions.dll, Raven.Client.Lightweight.dll,
# Microsoft.CompilerServices.AsyncTargetingPack.Net4.dll, and Raven.Smuggler.exe in a lib folder
# under the location of this script. You can find them in the folder where Octopus Deploy is installed.
[CmdletBinding()]
Param(
[Parameter(Mandatory=$false,Position=1)]
[string]$exportPath = ".\dump.raven",
@Damovisa
Damovisa / gist:fb6dc48038a2c2ad9216
Last active August 29, 2015 14:19
Get all parent and child steps for all projects
$octoBase = "http://octopusserver:port"
$apiKey = "API-XXXXXXXXXX"
Function GetFromOctopus([string]$relUrl) {
return Invoke-RestMethod -Uri "$octoBase$relUrl\?apiKey=$apiKey" -Method Get
}
$projects = GetFromOctopus -relUrl "/api/projects/all"
ForEach ($p in $projects.Items) {
$processLink = $p.Links.DeploymentProcess
@Damovisa
Damovisa / ConsoleScript.js
Created May 13, 2015 06:26
Javascript for the Octopus Environments page to enable/disable all machines in an environment
var OctoTool = {
GetEnvironmentMap: function(machineStatus) {
var machinesByEnv = angular.element($('.octo-group-body.machines')).scope().environments.map(function(el, i) {
var em = angular.element($('.octo-group-body.machines')).scope().machines[el.Id];
return {EnvironmentId: el.Id, OnlineMachines: em ? em[machineStatus] : null} ;
})
var values = {};
for (var i=0; i<machinesByEnv.length; i++) {
values[machinesByEnv[i].EnvironmentId] = machinesByEnv[i].OnlineMachines;
}
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,Position=1)]
[string]$OctopusUrl = "http://localhost:80",
[Parameter(Mandatory=$true,Position=2)]
[string]$ApiKey,
[Parameter(Mandatory=$false,Position=3)]
[switch]$Delete
@Damovisa
Damovisa / Disable_Enable_All_Machines.ps1
Created August 20, 2015 00:13
Disable or Enable all machines in an environment
Function Get-OctopusEnvironmentMachines{
Param(
[string]$EnvironmentName, #"App1 DEV"
[string]$APIKey, #API-XXXXXXXXXXXXXXXXXXXXXXXXX
[string]$OctopusBaseURI #http://octopus
)
try{
$environmentsJSON=Invoke-WebRequest -URI "$OctopusBaseURI/api/environments" -Header @{ "X-Octopus-ApiKey" = $apiKey } -Method GET;
}catch{
throw "Get-OctopusEnvironmentMachines: Failed to retrieve list of environments :: $_ "
{
"Id": "ActionTemplates-41",
"Name": "Chain Deployment",
"Description": "Trigger a deployment for another project in Octopus",
"ActionType": "Octopus.Script",
"Version": 10,
"Properties": {
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.ScriptBody": "Write-Host \"**********\"\nWrite-Host \"Chained Deployment of '$Chain_ProjectName' version '$Chain_ReleaseNum' to '$Chain_DeployTo'.\"\nswitch ($Chain_CreateOption) {\n \"Try\" { Write-Host \" Release will be created if it doesn't exist.\" }\n \"Create\" { Write-Host \" Release will be created before deploying.\" }\n \"NoCreate\" { Write-Host \" Release will not be created and should already exist.\" }\n}\nWrite-Host \"**********\"\n\n$baseUri = $OctopusParameters['Octopus.Web.BaseUrl']\n$reqheaders = @{\"X-Octopus-ApiKey\" = $Chain_ApiKey }\n\n# Find Environment\n$environments = Invoke-WebRequest \"$baseUri/api/environments/all\" -Headers $reqheaders -UseBasic
function Invoke-OctopusLogoUpload
{
[CmdletBinding()]
PARAM
(
[string][parameter(Mandatory = $true)][ValidateNotNullOrEmpty()]$InFile,
[string]$ContentType,
[Uri][parameter(Mandatory = $true)][ValidateNotNullOrEmpty()]$Uri,
[string][parameter(Mandatory = $true)]$ApiKey
)
@Damovisa
Damovisa / Asserṭ.cs
Last active April 29, 2017 18:38
We don't need no stinkin' tests (yes, this is a joke)
namespace Microsoft.VisualStudio.TestTools.UnitTesting
{
public static class Asserṭ
{
public static void AreEqual(Object expected, Object actual, params object[] parameters) { }
public static void AreEqual<T>(T expected, T actual, params object[] parameters) { }
public static void AreNotEqual(Object expected, Object actual, params object[] parameters) { }