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 / Reset-Activities.txt
Created April 13, 2015 14:54
Reset activities on Octopus Server
cd \Program Files\Octopus Deploy\Octopus
octopus.server service --stop
octopus.server reset-activities
octopus.server service --start
@Dalmirog-zz
Dalmirog-zz / skipstep.ps1
Created April 14, 2015 13:48
Skip step (stolen from Henrik :) )
Add-Type -Path "C:\Program Files\Octopus Deploy\Octopus\Octopus.Client.dll"
$baseUri = "http://localhost/octopus"
$apiKey = "API-xxxxxxxxxxxxxxxxxxxxxxxxx"
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $baseUri, $apiKey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint
$project = $repository.Projects.FindByName("MyProject")
$deploymentProcess = $repository.DeploymentProcesses.Get($project.DeploymentProcessId)
@Dalmirog-zz
Dalmirog-zz / AddStepTemplate.ps1
Created April 16, 2015 18:56
Add step template
$OctopusAPIKey = "YourApiKey"
$OctopusURL = "YourOctopusURL"
$header = @{ "X-Octopus-ApiKey" = $OctopusAPIKey }
$steptemplateJson = Get-Content .\StepTemplate.txt #This file should contain the full Json of the step template
Invoke-RestMethod $OctopusURL/api/actiontemplates -Method Post -Headers $header -Body $steptemplateJson
@Dalmirog-zz
Dalmirog-zz / Get deployment Log.cs
Created April 16, 2015 20:13
Get deployment Log
var endpoint = new OctopusServerEndpoint(server, apiKey);
var repository = new OctopusRepository(endpoint);
var deployment = repository.Deployments.Get("deployments-1126");
var task = repository.Tasks.Get(deployment.Links["Task"]);
var details = repository.Tasks.GetDetails(task);
@Dalmirog-zz
Dalmirog-zz / ScriptForHarbinder.ps1
Last active August 29, 2015 14:19
Script For Harbinder
$webSiteName = $OctopusParameters['Octopus.Action[Deploy Workware Legacy].IISWebSite.WebSiteName']
$appPoolName = $OctopusParameters['Octopus.Action[Deploy Workware Legacy].IISWebSite.WebSiteName']
Write-Output "Web Site: $webSiteName"
Write-Output "App Pool: $appPoolName"
Import-Module WebAdministration -Force
$webSite = Get-Website -Name $webSiteName
@Dalmirog-zz
Dalmirog-zz / MoveLibVarToProj.ps1
Created April 22, 2015 23:56
Move library variables to project
$baseUri = "http://urltooctopus" #Update this
$apiKey = "API-xxxxxxxxxxxxxxxxxxxxxxxxxxx" #Update this
$headers = @{"X-Octopus-ApiKey" = $apiKey}
$libraryVariableSetId = "LibraryVariableSets-1" #Update this
$projectName = "test" #Update this
function Get-OctopusResource([string]$uri) {
Write-Host "[GET]: $uri"
return Invoke-RestMethod -Method Get -Uri "$baseUri/$uri" -Headers $headers
}
@Dalmirog-zz
Dalmirog-zz / Get-DeploymentStatus.ps1
Created April 23, 2015 13:49
Get Deployment Status
$baseUri = "" #Update this
$apiKey = "" #Update this
$headers = @{"X-Octopus-ApiKey" = $apiKey}
$DeploymentID = "" #Update this. ie deployments-835
function Get-OctopusResource([string]$uri) {
Write-Host "[GET]: $uri"
return Invoke-RestMethod -Method Get -Uri "$baseUri/$uri" -Headers $headers
}
@Dalmirog-zz
Dalmirog-zz / t.ps1
Created May 4, 2015 15:23
Update Octopus variables by name
#Easiest way to get these dlls is to find them
#on the tentacle/Octopus install dir like i'm doing here
Add-Type -Path "C:\Program Files\Octopus Deploy\Tentacle\Newtonsoft.Json.dll"
Add-Type -Path "C:\Program Files\Octopus Deploy\Tentacle\Octopus.Client.dll"
Add-Type -Path "C:\Program Files\Octopus Deploy\Tentacle\Octopus.Platform.dll"
$OctopusURL = "" #eg "http://BestDeploymentTool.mycompany.com"
$APIKey = "" #eg "API-YHMOPNVMRLFXJBV4EQRDIDNDJ"
@Dalmirog-zz
Dalmirog-zz / t.ps1
Created May 6, 2015 13:33
HealthCheck by environment name
##Config
$APIKey = "Your API Key"
$OctopusURL = "Your Octopus URL"
$EnvironmentName = "Your Environment Name"
$header = @{ "X-Octopus-ApiKey" = $APIKey }
##
$Environment = (Invoke-RestMethod "$OctopusURL/api/Environments/all" -Method Get -Headers $header) | ?{$_.name -eq $EnvironmentName}
$body = @{Arguments = @{EnvironmentID = $Environment.Id
@Dalmirog-zz
Dalmirog-zz / addartifact.cs
Created May 8, 2015 14:57
Add artifact to release
var endpoint = new Octopus.Client.OctopusServerEndpoint(baseUri, apiKey);
var repository = new Octopus.Client.OctopusRepository(endpoint);
var project = repository.Projects.FindByName(projectName);
var release = repository.Projects.GetReleaseByVersion(project, releaseVersion);
var artifact = new Octopus.Client.Model.ArtifactResource
{
Filename = fileName,
RelatedDocumentIds = new Octopus.Platform.Model.ReferenceCollection(new [] { project.Id, release.Id })
};