Skip to content

Commit

Permalink
fix(pipeline): load kv based on branch in scheduled drift detection (#31
Browse files Browse the repository at this point in the history
)
  • Loading branch information
julie-ng authored Jun 29, 2021
1 parent 3b29b3e commit 65f7bb4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
13 changes: 5 additions & 8 deletions azure-pipelines/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ pool:

variables:
- template: vars/global.yaml
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}:
- group: e2e-gov-demo-dev-kv
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/production') }}:
- group: e2e-gov-demo-kv

stages:
- template: stages/ci.yaml

- stage: cd_stage
displayName: CD Stage

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

displayName: CD - Deployment
jobs:
- job: deploy
displayName: Terraform Plan and Apply
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines/schedule-drift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ schedules:

variables:
- template: vars/global.yaml
- ${{ if eq(variables.isMain, 'True') }}:
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}:
- group: e2e-gov-demo-dev-kv
- ${{ if eq(variables.isProduction, 'True') }}:
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/production') }}:
- group: e2e-gov-demo-kv

steps:
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines/stages/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
stages:
- stage: CIStage
displayName: CI
displayName: CI - Integration
jobs:
- job: CIJob
displayName: Terraform - Lint and Validate
Expand Down
15 changes: 8 additions & 7 deletions azure-pipelines/steps/confirm-kv-loaded.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
steps:
- bash: |
echo ""
echo ""
echo "***** Confirm Key Vault Integration *****"
echo "Fail pipeline if no key vault is loaded before Terraform tries and fails."
echo "--------------------------------"
echo "Confirm Key Vault 🔑 Integration"
echo "--------------------------------"
echo "KV_DEBUG_ENV: $KV_DEBUG_ENV"
echo ""
if [ "$KV_DEBUG_ENV" = '$(kv-debug-env)' ]; then
echo "Key Vault not loaded. If loaded properly, debug env value would be 'dev' or 'production'."
echo "⛔️ Key Vault not loaded"
echo "Please double check configuration Variable Groups in Azure Pipelines UI and that the YAML pipeline is running against the `main` or `production` branch."
exit 1
else
echo "Key Vault loaded for: $KV_DEBUG_ENV"
echo "Key Vault loaded"
fi
displayName: Debug - Key Vault loaded?
env:
KV_DEBUG_ENV: $(kv-debug-env)
KV_DEBUG_ENV: $(kv-debug-env)

4 changes: 4 additions & 0 deletions azure-pipelines/steps/debug-vars.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
steps:
- bash: |
echo ""
echo "---------"
echo "Debugging"
echo "---------"
echo "isMain: ${{ variables.isMain }}"
echo "isProduction: ${{ variables.isProduction }}"
echo "Build.SourceBranch: ${{ variables['Build.SourceBranch'] }}"
Expand Down

0 comments on commit 65f7bb4

Please sign in to comment.