Reputation: 147
In the classic release pipeline when you rerun a release build the same variables that were used when the release was initially created were used. In multi stage pipeline I am seeing the value is picked freshly/newly when even when we rerun the existing deployed stage.
Expected: Use the same variable which was used in the initial run rather than using the new one.
The variable which I am referring being overridden is read from Keyvault which is kept in the Azure DevOps variable group.
https://github.com/MicrosoftDocs/azure-devops-docs/issues/7663
Upvotes: 0
Views: 1616
Reputation: 103
I know this is an old question, but as I found myself here looking for a solution to this issue I thought I'd add an answer/work around for anyone else who may require it.
As already answered, with yaml pipelines, the library variables will always retrieve the current variable value from the variable group even if re-running an old completed pipeline.
As a work around solution I have done the following:
- publish: '$(Build.ArtifactStagingDirectory)/deployment.yaml'
artifact: 'deployment'
displayName: 'Publishing the deployment yaml file'
- task: DownloadPipelineArtifact@2
inputs:
artifactName: 'deployment'
targetPath: $(Build.ArtifactStagingDirectory)/bin
$(Build.ArtifactStagingDirectory)/bin/deployment.yaml
The downloaded versions of the yaml files still contain the variable values from when the file was first published. Therefore if you need to re-run an old pipeline, the old variable values will be used. The published yaml files exist for as long as the record of your pipeline exists in Azure DevOps.
Upvotes: 0
Reputation: 31083
Any changes made centrally to a variable group, such as a change in the value of a variable or the addition of new variables, will automatically be made available to all the definitions or stages to which the variable group is linked. In YAML pipeline, to use a variable from a variable group, you need to add a reference to the group in your YAML file:
variables:
- group: my-variable-group
So each time you run or rerun a YAML pipeline, it will get the variables from the variable group. If there is any changes made to variable group, the pipeline will get the new changes.
While in the classic release pipeline, the variables won't change in the variable group linked to an existing release, so when you redeploy the pipeline or stages, you can still use the original variables.
It's the default behavior of classic release pipeline and YAML pipeline, we can not change it.
Upvotes: 2