Skip to content

Instantly share code, notes, and snippets.

View Dalmirog-zz's full-sized avatar

Dalmiro Granas Dalmirog-zz

View GitHub Profile
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 = '[]'
$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
##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-zz
Dalmirog-zz / file.ps1
Created December 6, 2016 18:55
Get nuget package on Tentacle with clean name and do something with it
$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
}
  • 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-zz
Dalmirog-zz / setMaintenanceModeOffFromDB.sql
Created November 9, 2016 18:02
Turn off maintenance mode from DB
UPDATE [dbo].[Configuration]
SET [JSON] = '{"IsInMaintenanceMode":false}'
WHERE ID = 'maintenance'
GO
SELECT * FROM [dbo].[Configuration]
@Dalmirog-zz
Dalmirog-zz / email.html
Created November 1, 2016 13:52
Octopus email with log link for failed steps
<html>
<head>
<style type="text/css">
body{
font-family: 'Segoe UI';
font-size: 14px;
}
.bold {
font-weight: bold;
}
@Dalmirog-zz
Dalmirog-zz / CheckHealthSkippingDrives.ps1
Last active November 2, 2016 15:47
Checks Tentacle's health but skipping a few drives
$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} }
}
http://articulo.mercadolibre.com.ar/MLA-639072476-cactus-_JM
@Dalmirog-zz
Dalmirog-zz / GetPackagesFolder.ps1
Created October 10, 2016 19:42
GetPackagesFolder
Function Get-PackagesLocalFolder {
$OctopusHomeDirectory = (Get-item (Get-ItemProperty HKLM:\SOFTWARE\Octopus\OctopusServer\OctopusServer).configurationFilepath).Directory
return "$OctopusHomeDirectory\Packages"
}