Issues icon indicating copy to clipboard operation
Issues copied to clipboard

Moving manual intervention steps out of a parent step, or cloning them copies the target roles. Manual intervention steps target roles are not configurable in the UI

Open IsaacCalligeros95 opened this issue 1 year ago • 2 comments

Severity

Low (One issue raised)

Version

All

Latest Version

I could reproduce the problem in the latest build

What happened?

When moving, a manual intervention out of a parent step the "Octopus.Action.TargetRoles" from the parent step is copied across. The manual intervention step does not allow for configurable TargetRoles in the UI. A customer has ran into this issue while running an Import/Export where the TargetRoles do not exist in their migrated environment and there's no UI element to remove this.

Reproduction

  • Create a regular Run a Script step and add a target role.
  • Create a manual intervention step as a child step, or move it into the Run a Script step.
  • Move this manual intervention step out of the parent step, the Octopus.Action.TargetRoles from the parent step will be copied across in the deployment process for the Manual intervention step.

Error and Stacktrace

NA

More Information

No response

Workaround

Delete the target roles using this support-provided script. Use the dry run flag first and ensure the updates are as expected.

`# Set up project variables. $octopusURL = "https://octopusURL (https://octopusurl/)" $APIKey = "API-XXXXXXXXXXXXXXX" $header = @{ "X-Octopus-ApiKey" = $APIKey } $spaceID = "Spaces-ID" $dryRun = $true

Grab all deployment processes.

$deploymentProcesses = Invoke-RestMethod -Method GET -uri "$($octopusUrl)/api/$($spaceID)/deploymentprocesses?&take=500" -headers $header

Go through each deployment process.

foreach($deploymentProcess in $deploymentProcesses.items){

# Check that process is not snapshot.
if(!$deploymentProcess.Id.contains("-s-")){
    foreach($step in $deploymentProcess.Steps){

        # If step contains target role scoping and if step is manual intervention:
        if($step.Properties.'Octopus.Action.TargetRoles'){
            if($step.Actions.ActionType -eq "Octopus.Manual"){

                # Extra check to be sure incorrect steps aren't modified.
                if($step.Actions.ActionType -eq "Octopus.Script"){
                    break
                }
                
                # Remove role scoping and PUT new process to project.
                $step.Properties.PSObject.Properties.Remove('Octopus.Action.TargetRoles')
                write-host "Script will modify step $($step.Name) in project $($deploymentProcess.ProjectId)"
                
                # Following 2 lines added to print project name out
                $projectName = (Invoke-RestMethod -Method GET -uri "$($octopusUrl)/api/$($spaceID)/projects/$($deploymentProcess.ProjectId)" -headers $header).Name
                write-host "Project: $projectName"

                if(!$dryRun){
                Invoke-RestMethod -method PUT -uri "$($octopusUrl)$($deploymentProcess.links.self)" -headers $header -body ($deploymentProcess | ConvertTo-JSON -depth 10)
                }
            }
        }
    
    }
}

}

if($dryRun){ write-host "Dry run enabled - to perform modifications of projects change dryRun variable to false" }`

IsaacCalligeros95 avatar Oct 24 '23 03:10 IsaacCalligeros95

Opening this one and closing the other as the description explains the problem better

droyad avatar Apr 05 '24 03:04 droyad

Release Note: Fix a bug where certain steps (e.g. manual intervention, email) were copying target roles of parent steps

N-lson avatar Jun 27 '24 00:06 N-lson

:tada: The fix for this issue has been released in:

Release stream Release
2024.3 2024.3.5162
2024.4+ all releases

Octobob avatar Sep 04 '24 02:09 Octobob