Skip to content

Instantly share code, notes, and snippets.

View hnrkndrssn's full-sized avatar

Henrik Andersson hnrkndrssn

View GitHub Profile
@hnrkndrssn
hnrkndrssn / README.md
Created April 11, 2020 02:11
Use keybase gpg key for git commit signing on MacOS

Install gpg

Install homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install gpg

brew install gnupg

@hnrkndrssn
hnrkndrssn / octokit2fa.linq
Created August 23, 2019 07:24
Handle 2FA authentication in Octokit.net
<Query Kind="Program">
<NuGetReference>Octokit</NuGetReference>
<Namespace>Octokit</Namespace>
<Namespace>System.Threading.Tasks</Namespace>
</Query>
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
hnrkndrssn / RegisterSSHTargetInOctopus.ps1
Created October 20, 2016 01:32
PowerShell script to register a new SSH target in Octopus using the REST API
$headers = @{"X-Octopus-ApiKey"="API-xxxxxxxxxxxxxxxxxxxxxxxxx"}
$environments = Invoke-RestMethod "http://url.to.octopus/api/environments/all" -Headers $headers -Method Get
$theEnvironment = $environments | ? { $_.Name -eq "TheEnvironmentName" }
$accounts = Invoke-RestMethod "http://url.to.octopus/api/accounts/all" -Headers $headers -Method Get
$theAccount = $accounts | ? { $_.Name -eq "TheAccount" }
$discovered = Invoke-RestMethod "http://url.to.octopus/api/machines/discover?host=hostnameoripaddress&type=Ssh" -Headers $headers -Method Get
@hnrkndrssn
hnrkndrssn / RetentionPolicyByDeploymentJournal_3_x.ps1
Last active September 2, 2016 06:19
Manual retention policy when a variable has been used for the package to be deployed
$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"
return
}
$projectId = $OctopusParameters["Octopus.Project.Id"]
@hnrkndrssn
hnrkndrssn / README.md
Last active July 14, 2016 00:07
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
hnrkndrssn / Step1CreateNewPollingTentacle.ps1
Last active August 7, 2017 04:19
Register a Polling Tentacle without opening up port 443 to the world
# 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
hnrkndrssn / Run.cs
Created September 29, 2015 05:59
Create library variable set to disable delta compression and add it to all projects in an Octopus instance
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 (https://keybase.io/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: