Azure DevOps:仅为 运行 设置条件变量

Azure DevOps: Set a conditional variable for Run only

我正在尝试寻找一种解决方案,让我们的开发人员能够部署不同版本的构建。我的思路是向我们的 cicd 配置添加一个 env 变量,然后在我们的 cd 剧本中评估该 var 是否为 None,如果是,则覆盖我们通常从包或 pom 文件中获取的版本。

这轮将从我们的 helm 和 docker 容器注册表中获取 XXX 版本,允许他们在没有旧版本的情况下回滚或快速高效地重新部署旧版本。

我看到 Azdo 提供了环境变量,但我想要的东西只能设置或存储来自管道的 运行 的环境变量,并且不会持久。

您可以配置 so-called 个队列时间变量。这个想法是你设置一个默认值,比如最新的,并检查用于在队列时间更改值:

If a variable appears in the variables block of a YAML file, its value is fixed and can't be overridden at queue time. Best practice is to define your variables in a YAML file but there are times when this doesn't make sense. For example, you may want to define a secret variable and not have the variable exposed in your YAML. Or, you may need to manually set a variable value during the pipeline run.

You have two options for defining queue-time values. You can define a variable in the UI and select the option to Let users override this value when running this pipeline or you can use runtime parameters instead. If your variable is not a secret, the best practice is to use runtime parameters.

To set a variable at queue time, add a new variable within your pipeline and select the override option.

Set a variable at queue time.

To allow a variable to be set at queue time, make sure the variable doesn't also appear in the variables block of a pipeline or job. If you define a variable in both the variables block of a YAML and in the UI, the value in the YAML will have priority.

参见: