有没有办法在变量组中设置变量

pka*_*ert 4 continuous-integration azure-devops azure-pipelines

我正在尝试共享来自不同管道的版本信息,以便以后使用它们在发布管道中创建发布配置。所以基本上我需要在不同的管道之间共享信息。

为了创建一个以某种方式独特的版本,我想始终使用git rev-parse HEAD.

我已经尝试使用变量组,但我只能读取它们而不能设置它们。而且我不知道 azure devops 支持的另一种方式,我当然可以使用文件并发布它们。

我使用了文档提供的示例。

#!/bin/bash
echo "##vso[task.setvariable variable=sauce]crushed tomatoes"
Run Code Online (Sandbox Code Playgroud)

我希望在变量组中获得一个更改变量,以便稍后在发布管道中读取该变量。任何帮助表示赞赏。

And*_*lin 5

可以通过 Azure devops CLI 完成。

创建 powershell 任务:

echo $env:AZURE_DEVOPS_EXT_PAT | az devops login
az devops configure -d organization=https://dev.azure.com/<your_organisation>/ project=<your_project>

az pipelines variable-group variable update --id <id_here> --name <name_here> --value <value_here>

Run Code Online (Sandbox Code Playgroud)

并像这样在任务中创建变量 在此处输入图片说明