This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$lifecycle = New-Object Octopus.Client.Model.LifecycleResource | |
$lifecycle.Name = "MyLifecycle" | |
#Default Retention Policy | |
$lifecycle.ReleaseRetentionPolicy = [Octopus.Platform.Model.RetentionPeriod]::new(0,[Octopus.Platform.Model.RetentionUnit]::Items) #Unlimmited Releases | |
#$lifecycle.ReleaseRetentionPolicy = [Octopus.Platform.Model.RetentionPeriod]::new(2,[Octopus.Platform.Model.RetentionUnit]::Days) #2 days | |
$lifecycle.TentacleRetentionPolicy = [Octopus.Platform.Model.RetentionPeriod]::new(0,[Octopus.Platform.Model.RetentionUnit]::Items) | |
#$lifecycle.TentacleRetentionPolicy = [Octopus.Platform.Model.RetentionPeriod]::new(10,[Octopus.Platform.Model.RetentionUnit]::Days) #10 days | |
New-OctopusResource -Resource $lifecycle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####Adding a new variable##### | |
$variableset = Get-OctopusVariableSet -Projectname Powershell -ResourceOnly | |
$newvariable = New-Object Octopus.Client.Model.VariableResource | |
$scope = New-Object Octopus.Platform.Model.ScopeSpecification | |
#Environment Scope | |
#$scope.Add([Octopus.platform.Model.Scopefield]::Environment,(New-Object Octopus.Platform.Model.ScopeValue("Environments-1"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#####Update existing variable##### | |
$variableset = Get-OctopusVariableSet -Projectname Powershell -ResourceOnly | |
#updating value of variable "OctopusPrintVariables" to "False" | |
$variableset.Variables | ?{$_.name -eq "OctopusPrintVariables"} | %{$_.value = "False"} | |
#update variable set on database | |
Update-OctopusResource -Resource $variableset -Force |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[string]$LockFile = "C:\Test\Lockfile.txt" | |
[int]$wait = 15 #seconds to wait before checking the content of $lockfile again. | |
#Creating $lockfile if it doesnt exist | |
If ((Test-Path $LockFile) -eq $false){ | |
Write-Output "$lockfile does not exist on $env:computername. Creating it..." | |
New-Item $LockFile -ItemType file -Verbose | |
"Available" | Out-File $LockFile | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Module URL: http://dalmirog.github.io/OctoPosh/ | |
##Function to add roles | |
function add-Machineroles([string]$rolename){ | |
$machines = Get-OctopusMachine | |
foreach ($machine in $machines) | |
{ | |
$machine.resource.roles.add($rolename) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$projects = Get-OctopusProject | |
$list = @() | |
$list += $projects.latestdeployments | |
#Presentation | |
#If all "Prod" environments name start with "Prod", they will all show up toghether | |
$list | Sort-Object EnvironmentName | Format-Table | |
#If all "Web" Projects name start with "Web", they will all show up toghether |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use "NameOfYourOctopusDatabase" /* <-- Change this */ | |
select JSON from Configuration | |
where id = 'builtinrepositoryconfigurations-single' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 1) Updating a Machine's roles | |
#getting the machine | |
$machine = Get-OctopusMachine -MachineName "MyMachine" | |
#updating the machine's roles | |
$machine.resource.roles.add("NewRoleToAdd") | |
$machine.resource.roles.Remove("OldRoleToRemove") | |
#Saving the machine resource on the database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Variables": [ | |
{ | |
"Name": "Variable1", | |
"Value": "Valuewow", | |
"Scope": { | |
"Environment": [ | |
"Staging" | |
], | |
"Machine": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Id": "ActionTemplates-321", | |
"Name": "Web Deploy - Publish Website (MSDeploy)", | |
"Description": "Ensure that Web Deploy 3.5 is installed on the system. The installer is downloaded from http://www.iis.net/downloads/microsoft/web-deploy if required.", | |
"ActionType": "Octopus.Script", | |
"Version": 1, | |
"Properties": { | |
"Octopus.Action.Script.ScriptBody": "[System.Reflection.Assembly]::LoadWithPartialName(\"Microsoft.Web.Deployment\")\r\n\r\n# A collection of functions that can be used by script steps to determine where packages installed\r\n# by previous steps are located on the filesystem.\r\n \r\nfunction Find-InstallLocations {\r\n $result = @()\r\n $OctopusParameters.Keys | foreach {\r\n if ($_.EndsWith('].Output.Package.InstallationDirectoryPath')) {\r\n $result += $OctopusParameters[$_]\r\n }\r\n }\r\n return $result\r\n}\r\n \r\nfunction Find-InstallLocation($stepName) {\r\n $result = $OctopusParameters.Keys | where {\r\n $_.Equals(\"Octopus.Action |