Reputation: 365
I am using Multi stage Azure pipelines. Using the Classic editor I am able to set the scope for a variable but using the YAML pipeline I cannot. How is this possible using YAML Multi Stage Pipelines?
Here is the Classic UI where i can set the scope.
Upvotes: 2
Views: 2787
Reputation: 103
The below method will help. In the below case I am changing in HTML file. You can use config or JSON etc. In HTML file in place of variable declare like
#{name}#
and
#{name2}#
- stage: Dev
displayName: Deploy to Dev
dependsOn: Build
variables:
name: valueDev
name2: valueDev2
jobs:
- deployment: Dev
displayName: Deploy to Dev
environment: Dev
strategy:
runOnce:
deploy:
steps:
- checkout: self
clean: true
- task: qetza.replacetokens.replacetokens-task.replacetokens@3
displayName: 'Replace tokens in **/*.config'
inputs:
targetFiles: '**/*.html'
tokenPrefix: '#{'
tokenSuffix: '}#'
- stage: Test
displayName: Deploy to Test
dependsOn: Dev
variables:
name: valueTest
name2: valueTest2
jobs:
- deployment: Test
displayName: Deploy to Test
environment: Test
strategy:
runOnce:
deploy:
steps:
- checkout: self
clean: true
- task: qetza.replacetokens.replacetokens-task.replacetokens@3
displayName: 'Replace tokens in **/*.config'
inputs:
targetFiles: '**/*.html'
tokenPrefix: '#{'
tokenSuffix: '}#'
Upvotes: 1
Reputation: 597
Actually you can, but you have to copy paste the variables in each '- stage' block.
Upvotes: 1
Reputation: 58981
You can't. Use a variable group and link the variable group to the desired scope or store secrets in an Azure keyvault or some other secure secret store.
Upvotes: 1