Skip to content

Instantly share code, notes, and snippets.

Avatar
😃
Doing too much at once.

Damian Maclennan DamianMac

😃
Doing too much at once.
View GitHub Profile
@DamianMac
DamianMac / build.sh
Created Mar 1, 2018
Cake .NET Core 2.0 bootstrapper
View build.sh
#!/usr/bin/env bash
##########################################################################
# This is a Cake bootstrapper script for Linux and OS X and netcore 2.0.
# Taken and tweaked a little from
# https://adamhathcock.blog/2017/07/12/net-core-on-circle-ci-2-0-using-docker-and-cake/
##########################################################################
# Define directories.
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
CAKE_VERSION=0.26.0
View boxstarter.txt
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
# Update Windows and reboot if necessary
Install-WindowsUpdate -AcceptEula
if (Test-PendingReboot) { Invoke-Reboot }
#Disable hibernate
@DamianMac
DamianMac / Queryprojectslifecycles.ps1
Last active Apr 6, 2016
Query and Update Octopus Deploy projects and lifecycles
View Queryprojectslifecycles.ps1
$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")
View 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 / logoupload.ps1
Created Apr 14, 2015
Upload Project Logo to Octopus Deploy with Powershell
View logoupload.ps1
$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 / DbUp.cs
Last active Jul 19, 2020
DbUp Config to exec all stored procedure scripts from a directory
View DbUp.cs
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 / gist:8211c53211136e88e9fe
Created Dec 14, 2014
Set directory permissions with powershell
View gist:8211c53211136e88e9fe
#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 / gist:cab420adb9f9a915b028
Created Oct 30, 2014
Create a release with Octopus Client API
View gist:cab420adb9f9a915b028
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:a944c0fcab6db531e7a5
Created Oct 30, 2014
Executing a Script Task via the Octopus API
View gist:a944c0fcab6db531e7a5
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";
View Promoting a release
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();
You can’t perform that action at this time.