Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing unnecessary parameters from VSTS task group

I have a task group which contains besides other tasks the Azure Key Vault task and the Azure Resource Group Deployment task. In the latter I want to override some parameters in the ARM template with values which come from the key vault.

The Secrets filter field in the Azure Key Vault task looks like secret1,secret2,secret3. These secrets are available as variables in other tasks with the same name like the secret names. So the Override template parameters field within the Azure Resource Group Deployment task has the value -p1 $(secret1) -p2 $(secret2) -p3 $(secret3).

The problem is that VSTS automatically picks the three variables as parameters for the task group. I don't want this to happen. These variables will be set and read out within the task group itself. They are like private fields within a class.

One way would be to remove the Azure Key Vault task and use Build and Release > Library > Variable groups instead. But there is no way to link variable groups to task groups.

like image 319
Yavuz Avatar asked Dec 19 '17 12:12

Yavuz


2 Answers

I think there is no way to remove variables from the parameters of the task group. This has to do with the inner workings of how VSTS processes variables within task groups. The blog post VSTS/TFS: Understanding Task Groups and its various use cases with setvariable logging command gives some insights of how variables within task groups behave. In the same blog post there is a workaround to what I want to achieve.

The task group will have the three additional parameters secret1, secret2, and secret3. When I add the task group to a release definition I have to fill in these values:

  • $(secret1) for the parameter secret1
  • $(secret2) for the parameter secret2
  • $(secret3) for the parameter secret3

To reduce errors and improve experience you can set these values as default values for the parameters in the task group. This way you only have to fill out the remaining required parameters which are needed for the task group.

Ugly, but works.

like image 65
Yavuz Avatar answered Sep 22 '22 18:09

Yavuz


I ran into the same issue. I found that you can remove unnecessary parameters (i.e. parameters supplied by variable groups) by exporting the Task Group to a JSON text file and reimporting.

Just edit the JSON file in notepad++, or your favorite JSON editor, and remove any unnecessary parameters before reimporting. After the import, they are gone.

Also note, that you could probably add new parameters the same way but I haven't tried it.

like image 28
Chris Gessler Avatar answered Sep 20 '22 18:09

Chris Gessler