Skip to content

Instantly share code, notes, and snippets.


Henrik Andersson hnrkndrssn

View GitHub Profile
hnrkndrssn /
Created Apr 11, 2020
Use keybase gpg key for git commit signing on MacOS

Install gpg

Install homebrew

ruby -e "$(curl -fsSL"

Install gpg

brew install gnupg

hnrkndrssn / octokit2fa.linq
Created Aug 23, 2019
Handle 2FA authentication in
View octokit2fa.linq
<Query Kind="Program">
static string product = "Octokit-LINQPad-2FA-Demo";
IGitHubClient _Client = new GitHubClient(new ProductHeaderValue(product));
string clientId = "client-id-of-your-registered-github-application";
string clientSecret = "client-secret-of-your-registered-github-application";
hnrkndrssn / RegisterSSHTargetInOctopus.ps1
Created Oct 20, 2016
PowerShell script to register a new SSH target in Octopus using the REST API
View RegisterSSHTargetInOctopus.ps1
$headers = @{"X-Octopus-ApiKey"="API-xxxxxxxxxxxxxxxxxxxxxxxxx"}
$environments = Invoke-RestMethod "" -Headers $headers -Method Get
$theEnvironment = $environments | ? { $_.Name -eq "TheEnvironmentName" }
$accounts = Invoke-RestMethod "" -Headers $headers -Method Get
$theAccount = $accounts | ? { $_.Name -eq "TheAccount" }
$discovered = Invoke-RestMethod "" -Headers $headers -Method Get
hnrkndrssn / RetentionPolicyByDeploymentJournal_3_x.ps1
Last active Sep 2, 2016
Manual retention policy when a variable has been used for the package to be deployed
View RetentionPolicyByDeploymentJournal_3_x.ps1
$deploymentJournalPath = Get-Item $env:TentacleJournal
if($deploymentJournalPath) {
$itemsToKeep = $null
$useItemsToKeep = [System.Int32]::TryParse($OctopusParameters["OctopusRetentionPolicyItemsToKeep"], [ref]$itemsToKeep)
if(-not $useItemsToKeep) {
Write-Host "Could not find the number of deployments to keep, ensure the lifecycle is set to keep a limited number of releases"
$projectId = $OctopusParameters["Octopus.Project.Id"]
hnrkndrssn /
Last active Jul 14, 2016
Updating a step template in Octopus to the latest version from the Octopus Deploy Library

How to use this script

  • Replace <YourOctopusUrl> with the URL of your Octopus server.
  • If you configured your Octopus server to not run at the root of the URL, replace <YourOctopusVDirIfAnyOtherwiseJustBlank> with the virtual directory you configured, otherwise remove it.
  • Replace <YourOctopusApiKey> with your API Key, see How to create an API Key for instructions.
  • Replace <TheStepTemplateToFindAndUpdate> with the name of the step template you want to update.
  • Run the script!
  • After the script has completed (successfully :fingerscrossed:), go to `Library -> Step Templates -> `` -> Usage and update all the projects that use the step template.
hnrkndrssn / Step1CreateNewPollingTentacle.ps1
Last active Aug 7, 2017
Register a Polling Tentacle without opening up port 443 to the world
View Step1CreateNewPollingTentacle.ps1
# Step 1 - Run this on the Tentacle server to create the new Tentacle
$tentacleName = 'P1'
$tentaclePort = 10933
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" create-instance --instance $tentacleName --config "C:\Octopus\$tentacleName\Tentacle-$tentacleName.config"
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" new-certificate --instance $tentacleName --if-blank
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" configure --instance $tentacleName --reset-trust
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" configure --instance $tentacleName --home "C:\Octopus\$tentacleName" --app "C:\Octopus\Applications\$tentacleName" --port $tentaclePort --noListen "True"
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" service --instance $tentacleName --install --start
hnrkndrssn / Run.cs
Created Sep 29, 2015
Create library variable set to disable delta compression and add it to all projects in an Octopus instance
View Run.cs
var octopusUrl = "http://octopus.url";
var apiKey = "API-xxxxxxxxxxxxxxxxxxxxxxxxxx";
var octopusServer = new Octopus.Client.OctopusServerEndpoint(octopusUrl, apiKey);
var repo = new Octopus.Client.OctopusRepository(octopusServer);
var newLibraryVariableSet = new Octopus.Client.Model.LibraryVariableSetResource();
newLibraryVariableSet.Name = "Skip Delta Compression";
newLibraryVariableSet.Description = "Provides a shared variable set to skip delta compression that can be included on projects that shouldn't use it.";
var skipDeltaCompressionVariableSet = repo.LibraryVariableSets.Create(newLibraryVariableSet);

Keybase proof

I hereby claim:

  • I am hnrkndrssn on github.
  • I am henrikandersson ( on keybase.
  • I have a public key whose fingerprint is D41A B58C 846E 8C96 187D 3C78 3B2D 53D3 A3ED B9A5

To claim this, I am signing this object: