Octopus.Script exported 2021-09-13 by bobjwalker belongs to ‘Octopus’ category.
Step template to block the release progression of an Octopus Deploy release so it cannot be promoted beyond the current environment.
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
Octopus Url
Block.Octopus.Url = #{Octopus.Web.BaseUrl}
The base url (https://samples.octopus.app
) of your Octopus Server. Defaults to Octopus.Web.BaseUrl
.
Octopus API Key
Block.Octopus.Api.Key =
The API key of a user who has permission to block releases.
Release Id to Block
Block.Octopus.Previous.Release.Id = #{Octopus.Release.CurrentForEnvironment.Id}
The Octopus ID (Releases-123
) of the release to block. Defaults to Octopus.Release.CurrentForEnvironment.Id
Reason
Block.Octopus.Reason =
The reason why this release is being blocked.
Script body
Steps based on this template will execute the following PowerShell script.
$apiKey = $OctopusParameters["Block.Octopus.Api.Key"]
$previousReleaseId = $OctopusParameters["Block.Octopus.Previous.Release.Id"]
$reason = $OctopusParameters["Block.Octopus.Reason"]
$octopusBaseUrl = $OctopusParameters["Block.Octopus.Url"]
$spaceId = $OctopusParameters["Octopus.Space.Id"]
$body = @{
Description = $reason
}
$bodyAsJson = $body | ConvertTo-JSON -Depth 10
$headers = @{"X-Octopus-ApiKey"="$apiKey"}
Write-Host "Blocking the release $previousReleaseId from progressing"
Invoke-RestMethod -Uri "$($octopusBaseUrl)/api/$($spaceId)/releases/$($previousReleaseId)/defects" -Method POST -Headers $headers -Body $bodyAsJSON -ContentType 'application/json; charset=utf-8'
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "78a182b3-5369-4e13-9292-b7f991295ad1",
"Name": "Block Release Progression",
"Description": "Step template to block the release progression of an Octopus Deploy release so it cannot be promoted beyond the current environment.",
"Version": 1,
"ExportedAt": "2021-09-13T16:14:01.845Z",
"ActionType": "Octopus.Script",
"Author": "bobjwalker",
"Packages": [],
"Parameters": [
{
"Id": "fc366d69-e56b-476b-8005-5431f1ce8c05",
"Name": "Block.Octopus.Url",
"Label": "Octopus Url",
"HelpText": "The base url (`https://samples.octopus.app`) of your Octopus Server. Defaults to `Octopus.Web.BaseUrl`.",
"DefaultValue": "#{Octopus.Web.BaseUrl}",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "f03e6e96-f1d5-4b91-9ae6-f67fd8ba043c",
"Name": "Block.Octopus.Api.Key",
"Label": "Octopus API Key",
"HelpText": "The API key of a user who has permission to block releases.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "Sensitive"
}
},
{
"Id": "cdcbd826-e075-476c-b67a-ddf0e75a576c",
"Name": "Block.Octopus.Previous.Release.Id",
"Label": "Release Id to Block",
"HelpText": "The Octopus ID (`Releases-123`) of the release to block. Defaults to `Octopus.Release.CurrentForEnvironment.Id`",
"DefaultValue": "#{Octopus.Release.CurrentForEnvironment.Id}",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "5c9c1d6a-ec08-4d79-b442-180f9d0460c6",
"Name": "Block.Octopus.Reason",
"Label": "Reason",
"HelpText": "The reason why this release is being blocked.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
}
],
"Properties": {
"Octopus.Action.RunOnServer": "true",
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptBody": "$apiKey = $OctopusParameters[\"Block.Octopus.Api.Key\"]\n$previousReleaseId = $OctopusParameters[\"Block.Octopus.Previous.Release.Id\"]\n$reason = $OctopusParameters[\"Block.Octopus.Reason\"]\n$octopusBaseUrl = $OctopusParameters[\"Block.Octopus.Url\"]\n$spaceId = $OctopusParameters[\"Octopus.Space.Id\"]\n\n$body = @{\n\tDescription = $reason\n}\n$bodyAsJson = $body | ConvertTo-JSON -Depth 10\n\n$headers = @{\"X-Octopus-ApiKey\"=\"$apiKey\"}\n \nWrite-Host \"Blocking the release $previousReleaseId from progressing\"\nInvoke-RestMethod -Uri \"$($octopusBaseUrl)/api/$($spaceId)/releases/$($previousReleaseId)/defects\" -Method POST -Headers $headers -Body $bodyAsJSON -ContentType 'application/json; charset=utf-8'"
},
"Category": "Octopus",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/block-progression.json",
"Website": "/step-templates/78a182b3-5369-4e13-9292-b7f991295ad1",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAC1QTFRFT6Tl////L5Pg8vj9Y67omsvwPJrisdfzfbzs5fL7y+T32Ov5isLucLXqvt31CJPHWwAABMJJREFUeNrs3deW4jAMAFDF3U75/89dlp0ZhiU4blJEjvQ8hYubLJsA00UCBCIQgQhEIAIRiEAEIhCBCEQgAhGIQAQiEIEIhD8kJm+t+QprfdKfB9HbYpx6CWfspj8HMi+gMgHL/AmQA8W3JTKH+ALFvzCeL0RbpyoCPE9IJeNOSQwh5Z3qd6yRGWQ2qi2cZQWxqj1WzQYSjeoJmJlAklOd4VlArOqPhQEkqBERToeMcfRJBkC0Uep8CfBpjz4JsHJ0zF3dkEWNje0kiB/sUC6eApndaIiCMyAa1PiwJ0AWhRGJHJJQHG2dC7h1rNbO1QOxSA7lNCkkKrQIpJCAB1GREILYIC1NAiwbpKFJgGWDNExcwGstfExcZBCHC6nOglshHtmhViLIig1RNBCN7qjtW8C0Z1UvJcC1Z9XmwMBzzvobmgAyEzgq91dtEEsBsQSQQAFZCSBAATEEEApHZbrVBIkkEIUPSVeB+KtALA0kXQUSrwKZBCIQBnk8Y4i5CsReBeKvkqLM+BCSDWJlrZFvGk9SRTHshkgjZCGAaArIxm3H3grhVzFlW2msfl1ca79UJ1bofYvsDHHlNdTZnlh5MghuPd5NdBDUNZHyCkfktIh03XzALGRPlBDPac7qgWjHZzWcmF5zmmkhidMQ6boKiDXcDTUEaylZqCGJ0Vjvu/fL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