Skip to content

Instantly share code, notes, and snippets.

View Dalmirog-zz's full-sized avatar

Dalmiro Granas Dalmirog-zz

View GitHub Profile
@Dalmirog-zz
Dalmirog-zz / getprojects.ps1
Last active October 19, 2015 16:48
Getting projects using the 3 methods
#Using Octopus.client (recommended if you are planning on automating more than just this simple GET in the future)
# You can get this dll from your Octopus Server/Tentacle installation directory or from
# https://www.nuget.org/packages/Octopus.Client/
Add-Type -Path 'Octopus.Client.dll'
$apikey = ''
$octopusURI = ''
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURI,$apikey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint
@Dalmirog-zz
Dalmirog-zz / script.cs
Created October 14, 2015 16:38
filterevents
void Main()
{
var octopusUrl = "http://octopus.url";
var apiKey = "API-XXXXXXXXXXXXXXXXXX";
var octopusServer = new Octopus.Client.OctopusServerEndpoint(octopusUrl, apiKey);
var repo = new Octopus.Client.OctopusRepository(octopusServer);
// Define other methods and classes here
var events = repo.Events.List();
@Dalmirog-zz
Dalmirog-zz / a.md
Last active September 25, 2015 18:16
@Dalmirog-zz
Dalmirog-zz / Tentacle.exe.config
Created September 22, 2015 16:25
Tentacle config with <generatePublisherEvidence enabled="false"/>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<appSettings></appSettings>
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
<system.diagnostics>
@Dalmirog-zz
Dalmirog-zz / script.ps1
Created September 15, 2015 20:36
Get all the variables scoped to a specific machine
#This script required the Octoposh module: http://dalmirog.github.io/OctoPosh/
$machine = "" #Name of the machine you want to look variables for.
$MachineID = Get-OctopusMachine -MachineName $machine -ResourceOnly | select -ExpandProperty Id
$variableSets = Get-OctopusVariableSet
$list = @()
foreach ($variableSet in $variableSets){
@Dalmirog-zz
Dalmirog-zz / script.ps1
Last active September 10, 2015 13:31
Remove Library variable set references from all projects
#Config
$OctopusAPIKey = ""
$OctopusURL = ""
$header = @{ "X-Octopus-ApiKey" = $OctopusAPIKey }
#Library Variable Set (LVS) to remove from projects
$LibraryVariableSetIDs = ("LibraryVariableSets-1","LibraryVariableSets-2")
#Getting all the projects on the Octopus instance
$AllProjects = Invoke-WebRequest "$OctopusURL/api/projects/all" -Headers $header | select -ExpandProperty Content | ConvertFrom-Json
@Dalmirog-zz
Dalmirog-zz / RemoveVariableSetAndModule.ps1
Created August 26, 2015 21:09
Removes specific Variable Sets or Script modules from all/some projects in Octopus. Octoposh Module is required
Import-Module Octoposh #You can get Octoposh from http://dalmirog.github.io/OctoPosh
$VariableSetName = "" #variable set NAME, not ID
$ScriptModuleName = "Test" #Script module NAME, not ID
$ProjectList = ""#leave empty if you want to check all the project in your Octopus instance. Else add names between double quotes separated by a comma
$VariableSet = Get-OctopusVariableSet -LibrarySetName $VariableSetName -ResourceOnly
$ScriptModule = Get-OctopusVariableSet -LibrarySetName $ScriptModuleName -ResourceOnly
$c = New-OctopusConnection
@Dalmirog-zz
Dalmirog-zz / octo-artifacts.ps1
Last active December 18, 2019 19:48 — forked from rirl/octo-artifacts.ps1
Download ALL artifacts for a given deployment from Octopus Deploy to the artifacts directory
# Try it in powershell...
[Reflection.Assembly]::LoadFile("C:\Program Files\Octopus Deploy\Tentacle\Newtonsoft.Json.dll")
[Reflection.Assembly]::LoadFile("C:\Program Files\Octopus Deploy\Tentacle\Octopus.Client.dll")
[Reflection.Assembly]::LoadFile("C:\Program Files\Octopus Deploy\Tentacle\Octopus.Platform.dll")
# Basic data
Write-Host "Setup..."
$octoKey=" Your API Key"
$octoUser=" Your user name"
$octoId=" Your deployment id, ie (deployments-1492)"
@Dalmirog-zz
Dalmirog-zz / script.ps1
Last active August 29, 2015 14:28
Add an environment to an existing phase
#### Adding an environment to an existing phase####
$lifecyclename = ""
$phasename = ""
$environmentID = "" #must be a single value
$lifecycle = Get-OctopusLifeCycle -LifeCycleName $lifecyclename -resourceonly
$lifecycle.Phases | ?{$_.name -eq $phasename } | %{$_.OptionalDeploymentTargets.Add($environmentID)} #Optional deploy Env
#$lifecycle.Phases | ?{$_.name -eq $phasename } | %{$_.AutomaticDeploymentTargets.Add($environmentID)} #Automatic deploy Env
@Dalmirog-zz
Dalmirog-zz / script.ps1
Last active August 29, 2015 14:28
Add phase to a lifecycle
#### Adding a phase to a lifecycle ####
$lifecycle = Get-OctopusLifeCycle -LifeCycleName "MyLifeCycle" -resourceonly
$phase = New-Object Octopus.Client.Model.PhaseResource
$phase.Name = "Staging"
$phase.OptionalDeploymentTargets.Add("Environments-20") #Adding optional Environment to phase
#$phase.AutomaticDeploymentTargets.Add("Environments-30") #Automatic Environment
$phase.MinimumEnvironmentsBeforePromotion = 0