Update template variable using jython


want to update template variable using jython before creating release


Here is Jython API
You can get the VariableID to be changed from the RestCall

obj = releaseApi.getVariable('Applications/Foldera281a4293f4c40/Releasebe3cfbfdf3384d38bc7a250e4235b98b/Variable72232b7cc65c4b')
obj.value = "newValue"

This should update your variable.


@gsajwan I may be missing something, but I can’t quite understand your answer. I came across this question while trying to find a solution to the scenario below:

  • I’d like to add code to my template to populate a variable calling an external REST API. Let’s say myVar=abc (abc being the response from the REST API that I called in Jython).

  • Then I’d like to reuse myVar in another step of the template (say, several steps ahead).

Your answer contains a folder ID and a release ID. First, in my case there wouldn’t be a release ID since I want to add this code to the template and ensure the code gets run when a release is created (so I don’t have a release ID yet because a release has not been created from the template). Second, how do I find the folder ID?