I’m still working through a similar problem with some of the ProjectVariables, which may be the same issue, but I’ll report back on what I figure out (if anything).
Please let me know if the example script helps you get unstuck there.
Also thank you for the update on the common variables fix. I was working on it on my end and trying a ton of ways to get it to save and having issues as well. I mostly work with our data via REST so Octopus.Client syntax can elude me at times.
Yes, our script is loosely based on that example. Just some syntactical difference, but accomplishes the same thing.
I figured out my issue. We have a mix of project variables that are conditionally needed/used. In some cases they just have a default value, and others, when they aren’t needed, we fill them in with a null value.
The problem I was having is that early in the script we load up all of the variables, and set their values. If the value isn’t needed, we set it to a null value, however later in the script we loop and add the default value to the variable set before writing it back to the server. In our case, when a variable doesn’t have a default value it was removing the null string and setting it to blank causing us to have empty vars on the server. The fix was to check if a default value had a length of 0, and not modify/remove the null string.