I’m in charge of the preproduction and production environments for my company so I have to add or modify the variables for these environments but when I have to deploy an “old” release (validated to go on production), I can’t because the processes are updated between this release and the last one and I can’t update the variables.
I would like to know if it’s possible to update the variables set of a release through the API ?
Bonus question : Is that possible to update the deployment processes of an old release ?
Thanks for reaching out. You can add a variable to a Project using the API(1) and then update the release’s variable snapshot(2) so the next time it runs with the latest values.
Script to add variables to a Project: https://gist.github.com/Dalmirog/89626e8fd7833ed8de09
Script to update a Release’s Variables Snapshot: https://gist.github.com/Dalmirog/1f77f6a329c4ab038eaa
You cannot update the deployment process of a Release. For this you’ll have to create a brand new one.
Hope that helps!
Thanks for your answer but I forgot to tell that I’m using the C# API library and I can’t find the release’s variables snapshot.
Here’s an example on C# to update the variable’s snapshot
Thanks it works but as I said in the inital post, I’m looking a way to avoid the error we have when we want to update the variables and the deployment process had changed (“The project’s deployment process has changed since this release was created. A new release must be created in order to ensure accurate variable snapshots.”)
Is that possible ?
I’m almost sure that that message only shows up when updating the variables from the Web UI. If this is what you are trying to avoid, its not possible.
Are you getting this message when updating the variables using the snippet I gave you? I believe you shouldn’t be getting it. If you are, could you please share me a screenshot of it and some repro steps so i can test it on my end?
Here’s the exception details :
Octopus.Client.Exceptions.OctopusValidationException was unhandled
Message: An unhandled exception of type ‘Octopus.Client.Exceptions.OctopusValidationException’ occurred in Octopus.Client.dll
Additional information: There was a problem with your request.
- The project’s deployment process has changed since this release was created. A new release must be created in order to ensure accurate variable snapshots.
You can see the code in the screenshot.
I’m sorry but i’m gonna need to see more of the code you are running. Just the exception is not enough to know whats going on.
Were you able to successfully run the code snippet i gave you without modifying it? Please try to test that first on a separate console project and let me know if it runs ok. This is just to know if the code i gave you is wrong, or if there’s something else wrong with the integration of that snippet on your code.
This morning, I updated Octopus to the last version (from 220.127.116.117 to 18.104.22.1680).
I redo my test and now, it works (with your snippet, with my code and on the web app).
I can’t reproduce the error. I’m going to do more test on the web app to find a project with the message and try to execute the snippet).