Skip to content

Instantly share code, notes, and snippets.

View DamianMac's full-sized avatar
😃
Doing too much at once.

Damian Maclennan DamianMac

😃
Doing too much at once.
View GitHub Profile
$server = "http://blah"
$apiKey = "API-XXXXXXXXXXXXXXXX"
$command = $($server + "/api/tasks")
$task = @{}
$task.Name = "Backup"
$task.Description = "Backup requested via API"
$body = $task | ConvertTo-Json
@DamianMac
DamianMac / gist:6dfa55f0c4762e52ecc1
Created October 24, 2014 14:50
Find a deployment for a project and environment
var deployment = repository.Deployments.FindOne(d => d.EnvironmentId == "Environments-65" && d.ProjectId == "projects-193");
var server = "http://yourserveraddress:8065/"; //Your server and IP address
var apiKey = "API-XXXXXXXXXXXXXXXXXXXXXXXXX"; // Get this from your 'profile' page in the Octopus web portal
var endpoint = new OctopusServerEndpoint(server, apiKey);
var repository = new OctopusRepository(endpoint);
var deployment = repository.Deployments.Get("deployments-774");
var newDeployment = new Octopus.Client.Model.DeploymentResource();
@DamianMac
DamianMac / gist:a944c0fcab6db531e7a5
Created October 30, 2014 02:16
Executing a Script Task via the Octopus API
var server = "http://yourserveraddress:8065/"; //Your server and IP address
var apiKey = "API-XXXXXXXXXXXXXXXXXXXXXXXXX"; // Get this from your 'profile' page in the Octopus web portal
var endpoint = new OctopusServerEndpoint(server, apiKey);
var repository = new OctopusRepository(endpoint);
var task = new Octopus.Client.Model.TaskResource();
task.Name = "AdHocScript";
task.Description = "Script invoked via API";
@DamianMac
DamianMac / gist:cab420adb9f9a915b028
Created October 30, 2014 04:13
Create a release with Octopus Client API
var server = "http://yourserveraddress:8065/"; //Your server and IP address
var apiKey = "API-XXXXXXXXXXXXXXXXXXXXXXXXX"; // Get this from your 'profile' page in the Octopus web portal
var endpoint = new OctopusServerEndpoint(server, apiKey);
var repository = new OctopusRepository(endpoint);
var projectId = "projects-225"; //your project id
//This pulls out the info you need, the same call that's made on the Create Release page in the UI
var template = repository.Client.Get<Octopus.Client.Model.ReleaseTemplateResource>("/api/deploymentprocesses/deploymentprocess-" + projectId + "/template");
@DamianMac
DamianMac / gist:8211c53211136e88e9fe
Created December 14, 2014 02:13
Set directory permissions with powershell
#create share and set permissions
New-Item -ItemType Directory $sharePathname
$inherit = [system.security.accesscontrol.InheritanceFlags]"ContainerInherit, ObjectInherit"
$propagation = [system.security.accesscontrol.PropagationFlags]"None"
$permission = 'IIS_IUSRS',"FullControl", $inherit, $propagation, "Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
@DamianMac
DamianMac / DbUp.cs
Last active November 22, 2021 14:02
DbUp Config to exec all stored procedure scripts from a directory
var upgrader =
DeployChanges.To
.SqlDatabase(connectionString)
.JournalTo(new NullJournal()) //means the execution won't get logged, so each script is run each time
.WithScriptsFromFileSystem("D:\\mystoredprocs\\")
.LogToConsole()
.Build();
var result = upgrader.PerformUpgrade();
@DamianMac
DamianMac / logoupload.ps1
Created April 14, 2015 01:36
Upload Project Logo to Octopus Deploy with Powershell
$octopusServerUri = "http://serveraddress"
$octopusApiKey = "API-APIKEY"
$projectId = "projects-1"
$filePath = "D:\photos\picture.jpg"
Write-Verbose "Attempting to push a new logo"
$logoUri = "$octopusServerUri/api/projects/$projectID/logo?apikey=$octopusApiKey"
Write-Host $logoUri
@DamianMac
DamianMac / keybase.md
Created May 26, 2015 23:39
keybase.md

Keybase proof

I hereby claim:

  • I am damianmac on github.
  • I am damianm (https://keybase.io/damianm) on keybase.
  • I have a public key whose fingerprint is 67AF B8C1 EAD1 A004 1018 5FD4 275B 9389 C485 BF68

To claim this, I am signing this object:

@DamianMac
DamianMac / Queryprojectslifecycles.ps1
Last active April 6, 2016 13:30
Query and Update Octopus Deploy projects and lifecycles
$server = " http://yourserver/" #your octopus server
$apiKey = "API-YOURAPIKEY" #you'll need to generate an API
$command = $($server + "/api/projects")
$projects = Invoke-RestMethod -Method Get -Uri $command -Header @{"X-Octopus-ApiKey"=$apiKey}
$projects.Items | Format-Table Id, Name, lifecycleId
$command = $($server + "/api/lifecycles")