我阅读了环境文档here并在环境资源下打开了一些问题,但是我发现无法实现我的目标:
我想使用参数化的Yaml模板,以便将其部署到如下所示的多个环境中:
parameters:
pool_name: ''
aks_namespace: ''
environment: ''
jobs:
- job: preDeploy
displayName: preDeploy
pool:
name: $(pool_name)
steps:
- template: cd_step_prerequisites.yml
- deployment: Deploy
displayName: Deploy
dependsOn: preDeploy
condition: succeeded()
variables:
secret_name: acrecret
pool:
name: dockerAgents
**environment: '$(environment).$(aks_namespace)'**
strategy:
runOnce:
deploy:
steps:
- template: cd_step_aks_deploy.yml
- job: postDeploy
displayName: postDeploy
dependsOn: Deploy
condition: succeeded()
pool:
name: $(pool_name)
steps:
- template: cd_step_postrequisites.yml
我想使用这种方法,以便仅在代码旁边托管一个最小的pipeline.yml,然后将所有模板放在不同的存储库中,并从主管道调用它们,如下所示:>
resources:
repositories:
- repository: self
- repository: devops
type: git
name: devops
- stage: CD1
displayName: Deploy to Alpha
jobs:
**- template: pipeline/cd_job_api.yml@devops**
parameters:
pool_name: $(pool_name)
aks_namespace: $(aks_namespace)
app_name: $(app_name)
app_image_full_name: $(app_image_full_name)
environment: alpha
然后,我将能够传递$ environment变量,以便从一个模板操纵多个部署目标(AKS群集/命名空间组)。 当前这似乎是不可能的,因为当我尝试运行管道时默认的AzureDevOps解析器失败,并显示消息“ $(environment environment environment不包含x名称空间)”,该消息告诉我变量未扩展。
此计划是否会很快实施?如果没有,是否有其他选择仅使用一个参数化的作业模板来部署到多个环境?