I have a Azure Devops pipeline that tries to replace part of a string variable value with a value from Azure KeyVault.
Given a KeyVault secret kvSecret with value this-is-my-secret, I want another variable foo with value this-is-your-secret.
jobs:
- job: WebApp
pool:
vmImage: 'windows-latest'
variables:
foo: $[replace(variables['kvSecret'], 'my', 'your')]
steps:
- task: AzureKeyVault@2
inputs:
azureSubscription: 'foo'
KeyVaultName: 'myKeyVault'
RunAsPreJob: true
Since logging is masked, I tested this by writing to a file:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
New-Item $(build.artifactstagingdirectory)\test.txt
Set-Content $(build.artifactstagingdirectory)\test.txt '$(foo)'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
The output is this-is-my-secret though.
