Azure / devops-governance

Example end-to-end Governance Model from CI/CD to Azure Resource Manager. Use this project to deploy example AAD, ARM and Azure DevOps resources to learn about e2e RBAC.
MIT License
189 stars 93 forks source link

fix(pipelines): var group conditional must use compile time syntax #40

Closed julie-ng closed 2 years ago

julie-ng commented 2 years ago

Not 100% sure why this doesn't work

variables:
- template: vars/global.yaml
- ${{ if eq(variables.isMain, 'True') }}:
  - group: e2e-gov-demo-dev-kv
- ${{ if eq(variables.isProduction, 'True') }}:
  - group: e2e-gov-demo-kv

but my guess is that variables.isMain etc. isn't immediately available because they are defined in vars/global.yaml and may not be able at compile time in the next line of code. Switching back to variables['Build.SourceBranch'] which is a predefined system variable and available from beginning.

So hoping this syntax works:

- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}:
  - group: e2e-gov-demo-dev-kv
azure-pipelines[bot] commented 2 years ago

🟢  No configuration drift detected

Source Version: ad22a76befe5d08448e5f75e4eab0251b0ea1d3d