OpsLevel - Create Deploy Event - Powershell

Octopus.Script exported 2021-06-27 by rocktavious belongs to ‘OpsLevel’ category.

Track deploys to your services across different environments in OpsLevel.

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

OpsLevel CLI Package

OL_PACKAGE =

The Package that contains the OpsLevel CLI

Service

OL_SERVICE = #{Octopus.Project.Name}

The service alias for the event

Description

OL_DESCRIPTION = #{Octopus.Release.Notes}

The description of the event

Environment

OL_ENVIRONMENT = #{Octopus.Environment.Name}

The environment for the event

Deploy Number

OL_DEPLOY_NUMBER = #{Octopus.Release.Number}

The deploy number of the event

Deploy URL

OL_DEPLOY_URL = #{Octopus.Web.ServerUri}#{Octopus.Web.DeploymentLink}

The deploy url of the event

Dedup Id

OL_DEDUP_ID = #{Octopus.Release.Id}

The dedup id for the event

Deployer Email

OL_DEPLOYER_EMAIL = #{Octopus.Deployment.CreatedBy.EmailAddress}

The email of the deployer who created the event

Deployer Name

OL_DEPLOYER_NAME = #{Octopus.Deployment.CreatedBy.Username}

The name of the deployer who created the event

Script body

Steps based on this template will execute the following PowerShell script.

if (Test-Path -Path #{Octopus.Action.Package[OpsLevel].ExtractedPath}\opslevel.exe -PathType Leaf) {
	@"
service: #{OL_SERVICE}
description: #{OL_DESCRIPTION}
environment: #{OL_ENVIRONMENT}
deploy-number: #{OL_DEPLOY_NUMBER}
deploy-url: #{OL_DEPLOY_URL}
dedup-id: #{OL_DEDUP_ID}
deployer:
  name: #{OL_DEPLOYER_NAME}
  email: #{OL_DEPLOYER_EMAIL}
#{if Octopus.Release.Package}
#{if Octopus.Release.Package[].Commits}
commit:
  sha: \"#{Octopus.Release.Package[0].Commits[0].CommitId}\"
  message: \"#{Octopus.Release.Package[0].Commits[0].Comment}\"
#{/if}
#{/if}
"@ | #{Octopus.Action.Package[OpsLevel].ExtractedPath}\opslevel.exe create deploy --log-level=WARN -i "#{OL_INTEGRATION_URL}" -f -
} else {
	Write-Host "Please ensure the `opslevel` CLI package is setup and installed!"
}

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "dbde3ef3-a81b-43ac-99ed-509660e54beb",
  "Name": "OpsLevel - Create Deploy Event - Powershell",
  "Description": "Track deploys to your services across different environments in [OpsLevel](https://www.opslevel.com/docs/insights/deploys/).",
  "Version": 3,
  "ExportedAt": "2021-06-27T16:57:30.362Z",
  "ActionType": "Octopus.Script",
  "Author": "rocktavious",
  "Packages": [
    {
      "Name": "OpsLevel",
      "Id": "15dca245-862f-410f-b5f4-753dbba6e8f8",
      "PackageId": null,
      "FeedId": null,
      "AcquisitionLocation": "Server",
      "Properties": {
        "Extract": "True",
        "SelectionMode": "deferred",
        "PackageParameterName": "OL_PACKAGE"
      }
    }
  ],
  "Parameters": [
    {
      "Id": "1f3a7c3e-246e-4767-b314-bfc46d77c9e7",
      "Name": "OL_PACKAGE",
      "Label": "OpsLevel CLI Package",
      "HelpText": "The Package that contains the OpsLevel CLI",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "Package"
      }
    },
    {
      "Id": "31ed8779-810d-43e0-a53c-90520b549dab",
      "Name": "OL_SERVICE",
      "Label": "Service",
      "HelpText": "The service alias for the event",
      "DefaultValue": "#{Octopus.Project.Name}",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Id": "033217c3-d9fe-4bf3-a353-5d51768b77e5",
      "Name": "OL_DESCRIPTION",
      "Label": "Description",
      "HelpText": "The description of the event",
      "DefaultValue": "#{Octopus.Release.Notes}",
      "DisplaySettings": {
        "Octopus.ControlType": "MultiLineText"
      }
    },
    {
      "Id": "1cc660c8-bb22-4ff3-bc09-d7488cd6c24a",
      "Name": "OL_ENVIRONMENT",
      "Label": "Environment",
      "HelpText": "The environment for the event",
      "DefaultValue": "#{Octopus.Environment.Name}",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Id": "c60fc4c7-b29c-4f0d-a7d3-691b0bad2a3e",
      "Name": "OL_DEPLOY_NUMBER",
      "Label": "Deploy Number",
      "HelpText": "The deploy number of the event",
      "DefaultValue": "#{Octopus.Release.Number}",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Id": "304310bc-600d-435d-9481-7a71bac9fc24",
      "Name": "OL_DEPLOY_URL",
      "Label": "Deploy URL",
      "HelpText": "The deploy url of the event",
      "DefaultValue": "#{Octopus.Web.ServerUri}#{Octopus.Web.DeploymentLink}",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Id": "53ee85df-3d25-4018-b3e2-0dd34eb721ea",
      "Name": "OL_DEDUP_ID",
      "Label": "Dedup Id",
      "HelpText": "The dedup id for the event",
      "DefaultValue": "#{Octopus.Release.Id}",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Id": "536caa2b-36b3-4a6a-b1ed-245ddea9e647",
      "Name": "OL_DEPLOYER_EMAIL",
      "Label": "Deployer Email",
      "HelpText": "The email of the deployer who created the event",
      "DefaultValue": "#{Octopus.Deployment.CreatedBy.EmailAddress}",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Id": "244d6d8f-a512-4211-8e9e-16ae7caca84a",
      "Name": "OL_DEPLOYER_NAME",
      "Label": "Deployer Name",
      "HelpText": "The name of the deployer who created the event",
      "DefaultValue": "#{Octopus.Deployment.CreatedBy.Username}",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.ScriptSource": "Inline",
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptBody": "if (Test-Path -Path #{Octopus.Action.Package[OpsLevel].ExtractedPath}\\opslevel.exe -PathType Leaf) {\n\t@\"\nservice: #{OL_SERVICE}\ndescription: #{OL_DESCRIPTION}\nenvironment: #{OL_ENVIRONMENT}\ndeploy-number: #{OL_DEPLOY_NUMBER}\ndeploy-url: #{OL_DEPLOY_URL}\ndedup-id: #{OL_DEDUP_ID}\ndeployer:\n  name: #{OL_DEPLOYER_NAME}\n  email: #{OL_DEPLOYER_EMAIL}\n#{if Octopus.Release.Package}\n#{if Octopus.Release.Package[].Commits}\ncommit:\n  sha: \\\"#{Octopus.Release.Package[0].Commits[0].CommitId}\\\"\n  message: \\\"#{Octopus.Release.Package[0].Commits[0].Comment}\\\"\n#{/if}\n#{/if}\n\"@ | #{Octopus.Action.Package[OpsLevel].ExtractedPath}\\opslevel.exe create deploy --log-level=WARN -i \"#{OL_INTEGRATION_URL}\" -f -\n} else {\n\tWrite-Host \"Please ensure the `opslevel` CLI package is setup and installed!\"\n}\n"
  },
  "Category": "OpsLevel",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/opslevel-create-deploy-event-ps.json",
  "Website": "/step-templates/dbde3ef3-a81b-43ac-99ed-509660e54beb",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAABKQSURBVHgB7Z1PkFTVFcbvpKzoRmblCodUhU2ApKILGdRSN6BYIZswiLoSgtkahK2ibsOILuO/caVBxBVWVNgIJTJkgVUyuklcDJJFWM1kE7PpvK/fu6Fpu2/fc9+79537+vtVTZVVznQ37/Z37znnnj8zvQJDCBlF7yeGEDIWCoQQBxQIIQ4oEEIcUCCEOKBACHFAgRDigAIhxAEFQogDCoQQBxQIIQ4oEEIcUCCEOKBACHFAgRDigAIhxAEFQogDCoQQBxQIIQ4oEEIcUCCKuLZuzAffGKKIGXY1aZ/1H4x58ytj3rhS/vfcBmOOzhvzxFZD2qVHgbTMxe+N+ePZ8vQYZvdmY155uBQMaQUKpC0gCAgDApnEs/cWP/dQKC1AgaRm2JzyhWZXK1AgKfnkH8a8eH60OeX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