为什么 Azure Pipelines 显示 "The environment does not exist or has not been authorized for use"?

Why does Azure Pipelines say "The environment does not exist or has not been authorized for use"?

在 Azure Pipelines YAML 中,您可以为 运行 中的作业指定环境。

  jobs:
    - deployment: Deploy
      displayName: Deploy
      environment: $(environment)

将新值传递到管道应该会自动在 DevOps 中创建环境。

但是,我最近在尝试部署到新环境时遇到此错误:

Job Deploy: Environment [environment-name] could not be found. The environment does not exist or has not been authorized for use.

我手动创建环境后,管道部署成功。

是否有任何配置或我遗漏的东西允许自动创建环境?

Why does Azure Pipelines say "The environment does not exist or has not been authorized for use"?

首先,您需要在安全环境中确定您是创作者

其次,确保 change/create 来自 yaml 编辑器的环境名称,而不是来自 repo。

如果以上对您没有帮助,请问您在项目Reader中扮演什么角色?

我有同样的问题,根据文档,无法以这种方式创建环境。

If you are using runtime parameters for creating the environment, it will fail as these parameters are expanded at run time. Environment creation happens at compile time, so we have to use variables to create the environment.

更多信息请查看here