Skip to content

Instantly share code, notes, and snippets.

Dalmiro Granas Dalmirog

Block or report user

Report or block Dalmirog

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View resetIISBindings.ps1
cls
##CONFIG##
$OctopusAPIkey = "" #Octopus API Key
$OctopusURL = "" #Octopus root url
$projectName = ""
##PROCESS##
$goodBinding = '[{"protocol":"http","port":"80","host":"","thumbprint":null,"certificateVariable":null,"requireSni":false,"enabled":true}]'
$badBinding = '[]'
View createLibraryVariableSetWithVariables.ps1
$MyLibrarySet = "MyVariableSet"
#Create an instance of a Library Set Object
$libraryVariableSet = Get-OctopusResourceModel -Resource LibraryVariableSet
#Add mandatory properties to the object
$libraryVariableSet.Name = $MyLibrarySet
#Create the Library Set
New-OctopusResource -Resource $libraryVariableSet
View PushFilesFromFolder.ps1
##CONFIG##
$OctoExe = "" #FULL path of the Octo.exe executable (i.e. c:\tools\octo.exe)
$OutputFolder = "" #Output folder where all packages are dropped
$BuildID = "" #<-- This should be the build ID variable that comes from Jenkins
$OctopusServer = "" #Octopus Server base URL
$OctopusAPIKey = ""#Octopus API Key
##PROCESS##
$FilterPattern = "*$BuildID.nupkg"
@Dalmirog
Dalmirog / file.ps1
Created Dec 6, 2016
Get nuget package on Tentacle with clean name and do something with it
View file.ps1
$OctopusPackage = get-item $OctopusParameters['Octopus.Tentacle.CurrentDeployment.PackageFilePath']
#Octopus adds a GUID to the package name when it drops them on disk (i.e MyPackage.20160309.10.nupkg-e9ba4f11-9303-485f-8abc-6ea6c3776588), so you need to get your hands a bit dirty to clean it up:
#Dir where the package with the clean name will be dropped
$CopyDir = "C:\TempPackages"
If(!(Test-Path $CopyDir)){
New-Item $CopyDir -ItemType Directory -verbose
}
View channelsStrategy.md
  • 1 Project
  • 2 Lifecycles
    • Lifecycle one can be called "Dev Only" and should only contain the "Dev" environment.
    • Lifecycle 2 "Default Lifecycle" should contain the rest of the environments.
  • 2 Channels
    • Channel "Dev Only" Will use the "Dev Only" lifecycle and will have a rule that will only deploy packages with the unstable tag
    • Channel "Default" will use "Default Lifecycle" and will have a rule to make it only deploy packages without tags.

You can read more about Channels configurations here: http://docs.octopusdeploy.com/display/OD/Channels You'll particularly want to pay attention to the Versioning Rules section: http://docs.octopusdeploy.com/display/OD/Channels#Channels-DefiningVersionRulesversionrules

@Dalmirog
Dalmirog / setMaintenanceModeOffFromDB.sql
Created Nov 9, 2016
Turn off maintenance mode from DB
View setMaintenanceModeOffFromDB.sql
UPDATE [dbo].[Configuration]
SET [JSON] = '{"IsInMaintenanceMode":false}'
WHERE ID = 'maintenance'
GO
SELECT * FROM [dbo].[Configuration]
@Dalmirog
Dalmirog / email.html
Created Nov 1, 2016
Octopus email with log link for failed steps
View email.html
<html>
<head>
<style type="text/css">
body{
font-family: 'Segoe UI';
font-size: 14px;
}
.bold {
font-weight: bold;
}
@Dalmirog
Dalmirog / CheckHealthSkippingDrives.ps1
Last active Nov 2, 2016
Checks Tentacle's health but skipping a few drives
View CheckHealthSkippingDrives.ps1
$freeDiskSpaceThreshold = 5GB
$skipdrives = ("D:")
Try {
Get-WmiObject win32_LogicalDisk -ErrorAction Stop | ? { ($_.DriveType -eq 3) -and ($_.FreeSpace -ne $null) -and ($SkipDrives -notcontains $_.DeviceID)} | % { CheckDriveCapacity @{Name =$_.DeviceId; FreeSpace=$_.FreeSpace} }
} Catch [System.Runtime.InteropServices.COMException] {
Get-WmiObject win32_Volume | ? { ($_.DriveType -eq 3) -and ($_.FreeSpace -ne $null) -and ($_.DriveLetter -ne $null) -and ($SkipDrives -notcontains $_.driveletter) } | % { CheckDriveCapacity @{Name =$_.DriveLetter; FreeSpace=$_.FreeSpace} }
Get-WmiObject Win32_MappedLogicalDisk | ? { ($_.FreeSpace -ne $null) -and ($_.DeviceId -ne $null)} | % { CheckDriveCapacity @{Name =$_.DeviceId; FreeSpace=$_.FreeSpace} }
}
View gist:43b31815d40d812e5803b6459c1745d4
http://articulo.mercadolibre.com.ar/MLA-639072476-cactus-_JM
View GetPackagesFolder.ps1
Function Get-PackagesLocalFolder {
$OctopusHomeDirectory = (Get-item (Get-ItemProperty HKLM:\SOFTWARE\Octopus\OctopusServer\OctopusServer).configurationFilepath).Directory
return "$OctopusHomeDirectory\Packages"
}
You can’t perform that action at this time.