Skip to content

Commit 2b3a031

Browse files
authored
Merge pull request #1600 from donnybell/patch-1
Create Manual-Intervention-User-Restrictions-Enforcement.json
2 parents 9f449cb + 3c81cdc commit 2b3a031

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"Id": "06080873-f7f1-47e9-aaac-7ec1927f8146",
3+
"Name": "Manual Intervention User Restrictions Enforcement",
4+
"Description": "Use directly after a Manual Intervention step to enforce additional restrictions.\n\nUse cases include: \n- Preventing users from approving their own deployments\n- Restricting certain users (up to 2) from approving deployments",
5+
"ActionType": "Octopus.Script",
6+
"Version": 1,
7+
"CommunityActionTemplateId": null,
8+
"Packages": [],
9+
"GitDependencies": [],
10+
"Properties": {
11+
"Octopus.Action.Script.ScriptSource": "Inline",
12+
"Octopus.Action.Script.Syntax": "PowerShell",
13+
"Octopus.Action.Script.ScriptBody": "$manIntStepName = $OctopusParameters[\"URE.ManualInterventionStepName\"]\n\nWrite-Host \"Created by: \"$OctopusParameters[\"Octopus.Deployment.CreatedBy.Username\"]\nWrite-Host \"Approved by: \"$OctopusParameters[\"Octopus.Action[$manIntStepName].Output.Manual.ResponsibleUser.Username\"]\n\nIf ($OctopusParameters[\"URE.PreventDeployerFromApproving\"] -eq $true) {\n $deploymentCreatedByUsername = $OctopusParameters[\"Octopus.Deployment.CreatedBy.Username\"]\n}\n$approvedByUsername = $OctopusParameters[\"Octopus.Action[$manIntStepName].Output.Manual.ResponsibleUser.Username\"]\n\nIf ($approvedByUsername -eq $deploymentCreatedByUsername) {\n Write-Warning \"The same user may not be used to both start the deployment and approve the deployment.\"\n Write-Warning \"Please retry the deployment with a different approver for the $manIntStepName step.\"\n throw \"Terminating deployment...\"\n}\nElse {\n $excludedUserList = $OctopusParameters[\"URE.ExcludedUsers\"].Split([System.Environment]::NewLine)\n If ($excludedUserList -contains $approvedByUsername) {\n Write-Warning \"The user $approvedByUsername may not approve this deployment.\"\n Write-Warning \"Please retry the deployment with a different approver for the $manIntStepName step.\"\n throw \"Terminating deployment...\"\n }\n}\n\nIf (($OctopusParameters[\"URE.PreventDeployerFromApproving\"] -ne $true) -and (!$excludedUserList)) {\n Write-Host \">>>PreventDeployerFromApproving set to FALSE\" \n Write-Host \">>>ExcludedUsers contain no value(s)\"\n}\nWrite-Host \"Check complete\"\nWrite-Host \"Continuing...\"\n "
14+
},
15+
"Parameters": [
16+
{
17+
"Id": "d3e12917-2af0-4cff-988a-083e30a36314",
18+
"Name": "URE.PreventDeployerFromApproving",
19+
"Label": "Prevent Deployer from approving?",
20+
"HelpText": "When enabled, this terminates a deployment when the user who initiated the deployment also approves the manual intervention step",
21+
"DefaultValue": "True",
22+
"DisplaySettings": {
23+
"Octopus.ControlType": "Checkbox"
24+
}
25+
},
26+
{
27+
"Id": "4ec5ca6e-b033-44f9-8746-e926d853b4ec",
28+
"Name": "URE.ManualInterventionStepName",
29+
"Label": "Manual Intervention step name",
30+
"HelpText": "Select the step name from drop down",
31+
"DefaultValue": "",
32+
"DisplaySettings": {
33+
"Octopus.ControlType": "StepName"
34+
}
35+
},
36+
{
37+
"Id": "fed4cffe-d286-4793-ac6b-0d0b3ac35b27",
38+
"Name": "URE.ExcludedUsers",
39+
"Label": "Excluded Users",
40+
"HelpText": "Usernames of users to be excluded from manual intervention approvals (one per line)",
41+
"DefaultValue": "",
42+
"DisplaySettings": {
43+
"Octopus.ControlType": "MultiLineText"
44+
}
45+
}
46+
],
47+
"StepPackageId": "Octopus.Script",
48+
"$Meta": {
49+
"ExportedAt": "2025-04-16T21:40:42.587Z",
50+
"OctopusVersion": "2025.2.6682",
51+
"Type": "ActionTemplate"
52+
},
53+
"LastModifiedBy": "donnybell",
54+
"Category": "Octopus"
55+
}

0 commit comments

Comments
 (0)