从VSTS任务组中删除不必要的参数

时间:2017-12-19 12:14:36

标签: azure-devops azure-pipelines-build-task

我有一个任务组,除了其他任务外,还包含Azure Key Vault任务和Azure资源组部署任务。在后者中,我想要使用来自密钥库的值覆盖ARM模板中的一些参数。

Azure Key Vault 任务中的 Secrets过滤器字段看起来像secret1,secret2,secret3。这些秘密可作为其他任务中的变量使用,其名称与秘密名称相同。因此, Azure资源组部署任务中的覆盖模板参数字段的值为-p1 $(secret1) -p2 $(secret2) -p3 $(secret3)

问题是VSTS会自动选择三个变量作为任务组的参数。我不希望这种情况发生。这些变量将在任务组本身中设置和读出。它们就像一个类中的私人领域。

一种方法是删除Azure Key Vault任务并使用构建和发布>图书馆>变量组代替。但是没有办法将变量组链接到任务组。

2 个答案:

答案 0 :(得分:2)

我认为无法从任务组的参数中删除变量。这与VSTS如何处理任务组中的变量的内部工作方式有关。博客文章VSTS/TFS: Understanding Task Groups and its various use cases with setvariable logging command提供了有关任务组中变量行为的一些见解。在同一篇博客文章中,有一个解决方法来实现我想要实现的目标。

任务组将有三个附加参数secret1,secret2和secret3。当我将任务组添加到版本定义时,我必须填写以下值:

  • $(secret1)参数 secret1
  • $(secret2)参数 secret2
  • $(secret3)参数 secret3

要减少错误并改善体验,您可以将这些值设置为任务组中参数的默认值。这样,您只需填写任务组所需的剩余必需参数。

丑陋,但有效。

答案 1 :(得分:1)

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.