How do I push step template default value updates to projects?

I have a custom step template that I wrote to login to a system to perform a task after every deploy to record some information. Recently, I had to change the credentials to the account used. I’ve updated my step template’s default values so that new deploy projects get the value. When I pushed the update to all the 70+ projects using it I noticed all of them still have the previous value for the login.

How do I update all of them? Do I need to edit them by hand?

Hi @Zoren_Manteuffel ,

Thank you for reaching out to Octopus - with regards to updating a steps default values - Octopus tries as much as possible to give you the least amount of surprises. In other words, although you may have updated the default credentials, this will not filter through to all the projects where the step template is used if there are credentials already in the credentials field of those other steps.

I do understand that knowing this won’t help in your situation however, I mention it only to provide context on the thinking behind updating step template default values.

Looking at your specific issue, there are two options for you:

  1. Go through all the projects where the step is used and manually update the credentials.
  2. Use the Octopus REST API and write a script to scan the projects in a given Space and update the credentials.

With regards to option #2, there is a REST API script here, which could be tweaked to your requirements.

You’d need to follow it pretty much word-for-word all the way through until you got to the # Get steps section where instead of:

if (($null -ne $step.Properties.'Octopus.Action.TargetRoles') -and ($step.properties.'Octopus.Action.TargetRoles'.Split(',') -Icontains $roleName ))

You would iterate through the project steps looking for and updating the credentials in the relevant step, so maybe something like:

if ($steptemplate.Actions.Properties[0].'uc_Username')
{
$userName = "MyNewDefaultUsername"
}

Use your browser’s Developer Tools to find the relevant REST API parameters:

Finally, upload the changes to Octopus, e.g.

Invoke-RestMethod -Method Put -Uri "$octopusURL/api/$($space.Id)/deploymentprocesses/$($project.DeploymentProcessId)" -Headers $header -Body ($deploymentProcess | ConvertTo-Json -Depth 10)

Of course, it would be remiss of me not to also help you future-proof your scripting work, by recommending that you add the credentials as a variable to a named variable set; which can then be linked to all the projects where the credentials are used.

That way, if the creds ever change again, you only have one place to update them! :slight_smile:

Regards

Mark

Hi Mark!

Thanks for your detailed explanation. Looking at my options, the processes are too varied for all of our projects that I think it’s better to do them all by hand. Regarding the global variable sets we have been using them and it’s my intent to use them from here out for minor things like this.