Reputation: 3761
I'm following the example here of passing in a name to a stages template and then using that name as a var for a stage name, but it just appears to be blank everytime.
Am I missing something?
I've tried using $(environment.uat)$(region.uk)
- but that comes through as stage_$(environment.uat)$(region.uk)Deploy
Caller
- template: "yaml-templates/stages-terraform-apply-deploy.yaml/@terraform-modules"
parameters:
name: ${{variables.environment.uat}}${{variables.region.uk}}Deploy
...omited...
Template
parameters:
backendAzureRmStorageAccountName: null
azureSubscription: null
workingDirectory: ci/terraform
varsFile: null
tfEnvironment: null
region: null
appName: null
packagePath: null
name: ""
dependsOn: null
stages:
- stage: stage_${{ parameters.name}}Deploy
jobs:
- deployment: Terraform
displayName: Azure ${{parameters.tfEnvironment}} ${{parameters.region}}
environment: ${{parameters.tfEnvironment}}
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: Package
- checkout: terraform-modules
- checkout: self
- template: "terraform-plan-apply.yaml/@terraform-modules"
parameters:
workingDirectory: ${{parameters.workingDirectory}}
azureSubscription: ${{parameters.azureSubscription}}
backendAzureRmStorageAccountName: ${{parameters.backendAzureRmStorageAccountName}}
environment: ${{parameters.tfEnvironment}}
varsFile: ${{parameters.varsFile}}
Upvotes: 0
Views: 3669
Reputation: 3761
I was trying to use macro variables $(my.var.name)
notation, and using dot notation for my ${{variables.var.name}}
- switching to $${{variables.my_var_name}}` made them resolve.
Upvotes: 1
Reputation: 2196
From your Template, no parameter named "stageName" is defined.
parameters:
backendAzureRmStorageAccountName: null
azureSubscription: null
workingDirectory: ci/terraform
varsFile: null
tfEnvironment: null
region: null
appName: null
packagePath: null
name: ""
dependsOn: null
If you are using this Template multiple times in your pipeline, then the below will be recognized as "stage_Deploy" since no value for ${{ parameters.stageName }}
- stage: stage_${{ parameters.stageName }}Deploy
"The Stage name stage_Deploy appears more than once"
Your error message also proves this. You need to define a parameter named "stageName" in your Template.
Modify as below:
Caller:
- template: "yaml-templates/stages-terraform-apply-deploy.yaml/@terraform-modules"
parameters:
stageName: devuk
...omited...
Template:
parameters:
backendAzureRmStorageAccountName: null
azureSubscription: null
workingDirectory: ci/terraform
varsFile: null
tfEnvironment: null
region: null
appName: null
packagePath: null
stageName: ""
dependsOn: null
Upvotes: 2