Skip to content

Instantly share code, notes, and snippets.

View PaulStovell's full-sized avatar

Paul Stovell PaulStovell

View GitHub Profile
## --------------------------------------------------------------------------------------
## Configuration
## --------------------------------------------------------------------------------------
$isEnabled = $OctopusParameters["Octopus.Action.IISWebSite.CreateOrUpdateWebSite"]
if (!$isEnabled -or ![Bool]::Parse($isEnabled))
{
exit 0
}
@PaulStovell
PaulStovell / Example.md
Created February 21, 2014 07:19
Example

I build a web application with an API, and we have an API client that we publish to NuGet when we release to production.

I want to have two steps in Octopus:

  • Deploy the web app
  • Push the API client to NuGet

I could write a script like this:

NuGet.exe push $OctopusParameters["Octopus.CurrentDeployment.PackagePath"]

"""
Generate release notes from a GitHub milestone.
Forked from here: https://gist.github.com/unbracketed/3380407
"""
MILESTONE_ID = 22 # The ID of the milestone (not the title) - get this from the query string
GITHUB_USER = '' # Your username
GITHUB_PASSWORD = '' # Your password
REPO = 'OctopusDeploy/Issues' # Format is username/repo
# Assumes that $appPoolName is set to the name of the application pool you want to modify. For example:
#
# $appPoolName = "DefaultAppPool"
# $appPoolName = $OctopusParameters["YourVariable"]
Import-Module WebAdministration
$appPoolStatus = Get-WebAppPoolState $appPoolName
if ($appPoolStatus.Value -eq "Stopped")
{
@PaulStovell
PaulStovell / Script.ps1
Last active August 29, 2015 14:00
Listing machines from PowerShell
# Don't forget to change the path below to your copy of Octopus.Client.dll
Add-Type -Path "C:\GitHub\OctopusDeploy\source\Octopus.Client\bin\Octopus.Client.dll"
$endpoint = new-object Octopus.Client.OctopusServerEndpoint "https://demo.octopusdeploy.com","API-RORM5DBGZMOSYGE7OSE5EZPQA"
$repository = new-object Octopus.Client.OctopusRepository $endpoint
$envId = $repository.Environments.FindByName("Production")
$machines = $repository.Environments.GetMachines($envId)
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Octofront.Web</id>
<version>1.0.0</version>
<authors>Octopus Deploy</authors>
<owners>Paul Stovell</owners>
<licenseUrl>http://octopusdeploy.com</licenseUrl>
<projectUrl>http://octopusdeploy.com</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
@PaulStovell
PaulStovell / StepA.ps1
Created May 28, 2014 07:30
Fun with output variables
# This is a PowerShell step.
# Name: StepA
# Runs on roles: app-server
Set-OctopusVariable -name "TestResult" -value "Passed"
# The variable will be available in other steps on other roles as:
#
# Octopus.Action[StepA].Output[App01].TestResult
#
public class ReleaseDeploymentsIndex : AbstractMultiMapIndexCreationTask<ReleaseDeploymentsIndex.ReduceResult>
{
public ReleaseDeploymentsIndex()
{
AddMap<Release>(releases =>
from release in releases
select new ReduceResult
{
ReleaseId = release.Id,
ProjectId = release.ProjectId,
@PaulStovell
PaulStovell / Branching.md
Last active August 29, 2015 14:04
Branching in Octopus

First, let's introduce a new concept called a BranchConfiguration:

{
    "Id": "branchconfig-project-1",
    "ProjectId": "project-1",
    "DefaultBranch": "master",
    "Branches": [
        {
            "Name": "master",      // There is always a default branch

"Steps": [

@PaulStovell
PaulStovell / Octopus.Features.IISWebSite_BeforePostDeploy.ps1
Created July 29, 2014 10:44
Patched Octopus.Features.IISWebSite_BeforePostDeploy.ps1 for .NET 3.5 sites
## --------------------------------------------------------------------------------------
## Configuration
## --------------------------------------------------------------------------------------
$isEnabled = $OctopusParameters["Octopus.Action.IISWebSite.CreateOrUpdateWebSite"]
if (!$isEnabled -or ![Bool]::Parse($isEnabled))
{
exit 0
}