Earlier(before config-as-code) I was using process step to update the Project variable via Rest API, however after enabling the config-as-code this started failing because project variables are stored as part of GIT and needs Commit to change it. How can this be fixed with config-as-code?
I wanted to let you know that earlier this year Octopus changed its policies around providing API scripts for customers. In the past, we’d get a request such as this, maybe ask a few clarification questions, write up an example script for you to modify, and send it over. Then a few days would go by as you attempted to modify it to fit your needs, but you’d find an error or some additional use case that wasn’t mentioned in earlier conversations, slowing down progress. It wasn’t a great experience for anyone.
Our new policy gives you two choices:
We point you in a general direction and provide some pseudo-code and endpoints to consider, but you’d write the script.
We now offer professional services where for a fee we’d write API script(s) for you. We’d meet with you, discuss your use case, conditions of satisfaction, any gotchas specific for your instance, and write something specifically for you.
The pseudo-code hasn’t been updated to accommodate CaC project variables, but we may do in the future. I checked this out, and there are a couple of things you need to do in the script to get this working;
You need to work out if the variable you’re adding is sensitive because sensitive variables are stored in the database still, and the API call to add these into Octopus remains the same.
For any none sensitive variables, then you need an additional parameter that includes the branch name you want to add the variables to.
Thanks @adam.close , Can you please point me to the Octopus official documentation that talks about including the branch name? If I could learn to find right documentation on the Octopus official site then probably I would refrain myself from asking the specific question like this as the policies has changed on Octopus side.
Our API documentation can be found here, but not everything you can do in the API is documented explicitly.
My recommendation is to use dev tools to record your actions in the Octopus UI. This will give you all the API calls Octopus makes when any UI button is clicked, which you can then use in your script. The below example is me adding a new variable in a project and committing it to my git repro with a commit message.