API to replace variables across all projects

Is there a way via the API to find all variables that contain a particular string, and change them to something else? For example, we have multiple variables (named different across projects) that all point to a particular VM URL such as http://ptr-d-media across all projects in an environment. The reason for the multiple names, and not using a variable set to represent this guy and others like it is because of constant churn, learning octopus deploy as we go, and figuring things out on the fly. Knowing what we know now, we would have done it differently, but we’re time-crunched at the moment. It would be nice to have an API endpoint that will search all variables, given an environment, across all projects, and change any values that match one string, to another string.

Failing that, I could poke around in the actual RavenDB… but, I’d rather not.

Hi Chris,

Thanks for reaching out, and sorry for the delay. I spent a good amount of time trying to make a script for you using just the REST API in Powershell, but i ran into a limitation of powershell when it comes to handling nested JSONs with squared brackets. Reason why i’m gonna give you a script to do this, but using the Octopus.client. At the beginning of the script you’re gonna have to reference the DLLs paths.

The script will run through every project’s variable sets, look for the value pattern and update it with the new value.

Hope it helps :slight_smile:

Dalmiro

Dalmiro - Schweet! This is very helpful for me. :slight_smile: