Skip to content

Release Pipeline

A recommended pipeline for the release consists of the following steps:

  1. Download the package containing the deployment scripts using the dynamic package selection.
  2. Download the DataStar templates package.
  3. Run the DataStar.Tools deployment in rollback mode using the step template provided.
  4. Manual step to review the output from the verification step.
  5. Run the DataStar.Tools deployment step to generate a reversal package and deploy the changes.
  6. Housekeeping step to remove packages.

Octopus Variables

Create a new project in Octopus and start by setting up the variables that are going to be required. We suggest that you create a Library Set for some of these variables so you can share them with the Reversal Project.

Name Description
LicenseKey A sensitive field containing the supplied DataStar license key.
PackageApiKey A sensitive field containing an API Key that you can use to publish reversal packages to the Octopus Feed.
ConnectionString The connection string you use to connect to each target database, this can contain other variable references if you have separate variables for the database username and password.
DynamicPackageName This will vary depending on your naming convention for the deployment artifacts package, for example if we were using a Jira reference DAT-243432 then the value would be DAT-#Octopus.Release.Number | Replace "\.?\d*$" "" }
RevertPackageName The name to be used for the reversal package, this should include the original package id as well as the environment so that it is clear which packages relate to which deployments. For example you might use the following naming: REVERT-#{Octopus.Environment.Name}-#{Octopus.Action[Download Package].Package.PackageId}.#{Octopus.Action[Download Package].Package.PackageVersion}.nupkg
HouseKeepDirectory A base directory location on the tentacle that will be used to hold the various packages: C:\Octopus\Temp\#{Octopus.Environment.Name}
TempDirectory A directory location on the tentacle that will be used to hold the various packages. We recommend using a custom temporary location so that the artifacts can be shared between steps without having to have the packages referenced by each step. For example you might set this to: #{HouseKeepDirectory}\#{Octopus.Action[Download Package].Package.PackageId}-#{Octopus.Action[Download Package].Package.PackageVersion}

You may need to setup additional variables, but the above should be the minimum that would be required.

Step 1 - Download Package

Create a step in your project that will download the deployment artifacts package using the DynamicPackageName variable, this can be done using the standard "Deploy A Package" step.

Step 2 - Download Templates

Create a step in your project that will download the deployment templates package, this can be done using the standard "Deploy A Package" step.

Step 3 - DataStar Verify

This step will use the step template that you installed for DataStar.Tools. It will be configured to run the deployment in rollback mode and output the log file as a artifact so that it can be reviewed in the next step. There are quite a few options available to you so you should refer to the DataStar.Tools documentation to decide which features you will be using. In the example below we just want to generate the verification output assuming we are using Microsoft SqlServer.

Note: #{WorkItem} and #{Version} will be created provided that you have a metadata.json file with these values populated in the deployment artifacts package. See Variables File below.

Name Value
Target database Microsoft
The name of the database environment #{Octopus.Environment.Name}
The connection string to connect to the target database #{ConnectionString}
Enable writing details to the auditing tables False
License Key #{LicenseKey}
Work Item / User Story #{WorkItem}
Version #{Version}
Reversal Enabled False
Working Directory #{TempDirectory}
DataStar Path #{Octopus.Action.Package[DataStarPackage].ExtractedPath}/content
Variables File metadata.json
DataStar Package Set to the feed and package containing the DataStar.Tools
Rollback Transaction True
Output Log File verify.txt

Step 4 - Review Deployment

Add a standard "Manual Intervention Required" step so that the deployment can be reviewed before proceeding.

Step 5 - DataStar Release

This step will use DataStar.Tools step template again. This time it will be configured to run the deployment in deployment mode, generate a reversal package and publish it to Octopus and output the log file as a artifact. Again there are quite a few options available to you so you should refer to the DataStar.Tools documentation to decide which features you will be using.

Note: #{WorkItem} and #{Version} will be created provided that you have a metadata.json file with these values populated in the deployment artifacts package. See Variables File below.

Name Value
Target database Microsoft
The name of the database environment #{Octopus.Environment.Name}
The connection string to connect to the target database #{ConnectionString}
Enable writing details to the auditing tables False
License Key #{LicenseKey}
Work Item / User Story #{WorkItem}
Version #{Version}
Reversal Enabled True
Working Directory #{TempDirectory}
Template Directory #{TempDirectory}/templates
Package File Name #{RevertPackageName}
Package Directory #{TempDirectory}/package
Package Invariant False
Package URI https://your-octopus-libary-feed/nuget/packages
Package API Key #{PackageApiKey}
API Key Header X-Octopus-ApiKey
DataStar Path #Octopus.Action.Package[DataStarPackage].ExtractedPath}/content
Variables File metadata.json
DataStar Package Set to the feed and package containing the DataStar.Tools
Rollback Transaction False
Output Log File output.txt

Step 6 - Remove Packages

A final step is added to run as script and is set to always run. This is a house keeping step and is required as we have installed our artifacts in a custom location so that they can be shared more easily between steps and now they need to be removed. The script below will delete the #{TempDirectory} and then clean up the parent directory #{HouseKeepDirectory} to remove anything older then 15 days as a safeguard in case any orphaned files where left behind from older executions.

$folderPath = $OctopusParameters["TempDirectory"]
Remove-Item $folderPath -Force  -Recurse -ErrorAction SilentlyContinue

$houseKeepPath = $OctopusParameters["HouseKeepDirectory"]
if (![string]::IsNullOrEmpty($houseKeepPath)) 
{
    $limit = (Get-Date).AddDays(-15)
    # Delete files older than the $limit.
    Get-ChildItem -Path $houseKeepPath -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force -Recurse
}

Note: this step is set to cannot skip and always run