When we try to add the step template File system : Find and Replace we are getting the error as below:
Actions names ‘File System - Find and Replace’, ‘Read File Content’ are already in use by other steps in this deployment process. Action names must be unique.
Here is the script:
function Execute-FindReplace($target, $find, $replace, $ignoreCase) {
$options = [System.Text.RegularExpressions.RegexOptions]::None
if ($ignoreCase) {
$options = [System.Text.RegularExpressions.RegexOptions]::IgnoreCase
}
Can you send through a screenshot of your current full deployment process, and the error you receive when trying to add another File System - Find and Replace step with a different name.
As I suspected, you have 2 steps that are named File System - Find and Replace and 2 steps that are named Read File Content already in your deployment process and if I remember correctly we had a bug a while back that allowed for this scenario to occur.
I’ve written up the C# script (can be run using LINQPad, link to script or just added to a .NET console app and run that way) below that should rename the duplicate steps so that you can start editing the deployment process again (please note: requires the Octopus.Clients and JSON.Net NuGet packages):
var octopusServer = "https://<your server address>";
var octopusApiKey = "API-AAAAAAAAAAAAAAAAAAAAAAAAA";
var endPoint = new OctopusServerEndpoint(octopusServer, octopusApiKey);
var repo = new OctopusRepository(endPoint);
var deploymentProcess = repo.DeploymentProcesses.Get("deploymentprocess-Projects-13");
var duplicateActionGroups = deploymentProcess.Steps.SelectMany(s => s.Actions).GroupBy(a => a.Name).Where(g => g.Count() > 1);
foreach(var duplicateActionGroup in duplicateActionGroups)
{
var i = 1;
foreach(var action in duplicateActionGroup)
{
action.Name = $"{action.Name} {i}";
i++;
}
}
repo.DeploymentProcesses.Modify(deploymentProcess);
You can run it using LINQPad (I’ve shared the script here so you can download it and open in LINQPad, update the octopusServer, octopusApiKey and deploymentProcessId values with your details).
Or, you can create a new .NET console app and add the script there and run it that way.
I recommend you take a DB backup before running the script just to be on the safe side, in case something goes wrong (it shouldn’t as the script is a pretty simple script and only affects 1 record in the database)