In a previous article I explained how you can add python on PATH when you install it on a windows container image.
However if you try to use the python verb immediately you may face a problem that variable is not recognized.
In order to resolve this issue you will have to reload the environmental variables so that change reflects the current powershell session that you use.
By performing the below powershell command you can reload env variables and continue the execution of your scripts with variables reloaded.
Following my previous article about how to update a variable group using POSTMAN, I will now document how to implement the same behavior through a pipeline.
First things first you will need a PAT. I have included this PAT in a different variable group than the one that I will update. this is because when you update the variable group, all the variables that are inside will get lost. If you need to retain them, you should have to get them first and then add them again on the variable group.
For this reason I have created a variable group named token-group which holds my PAT. I also made this variable a secret.
The variable group that I will update has the name of var-group and the id of 5.
The pipeline includes two tasks. The first task will loop through the variables on the group and print them out. The second task will update the variable group based on the JSON that you provided. You should change your ORG and project URLs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After running the pipeline you will notice a null output on the update of the variable group. This is the requested result and as task has not failed your var group will get updated.
I was struggling to update a variable group using the Azure DevOps Rest API. In this article I will document the procedure using POSTMAN.
First things first you should create a PAT in order to interact with the API. If you do not know how to create such a thing you should read my previous article about running a build through a REST api on which I documented also the creation of a PAT.
Then you will need to add the access token under authorization tab of POSTMAN using Type Basic Auth. The PAT should be added as plain text.
Then you will need to add Content-Type as application/json under Headers.
Then you will have to create your URL. This should be of the format:
Important: You should use the version=5.1-preview.1. If you use the latest version you will notice an error on the call. This is a bug that has not been fixed as I found online.
In my example I wanted to update the variable group with the ID 5 and add a variable named new-var. The body of your request should be like below. Keep in mind that we use the PUT HTTP verb to update the variable group. This means everything that is inside the variable group will be discarded. If you followed all the steps correctly you will notice the below output JSON. This should indicate success on the procedure.
Lastly you can locate your new variable inside the variable group.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here:
Cookie Policy