Based on Richard's answer, I managed to set the value of a variable in a variable group to a variable coming from a CI pipeline, and then to read that variable in a CD pipeline.
For that, it is necessary:
- To have previously created the variable group, and the variable (its name identified by
$(variableName)
. Let's assume its value would be stored in $(variableValue)
).
- To find the variable group ID (stored in
$(variableGroupId)
), which can be done by navigating on Azure DevOps to that variable group. The group ID will then be in the URL.
- A Personal Access Token (PAT) with Read & Write access to group variables (called
$(personalAccessToken)
)
CI pipeline
- powershell: |
az pipelines variable-group variable update --group-id $(variableGroupId) --name $(variableName) --value $(variableValue)
displayName: 'Store the variable in a group variable'
env:
AZURE_DEVOPS_EXT_PAT: $(personalAccessToken)
Then all that's necessary, is to declare the variable group in the CD pipeline. If this variable group is called MyVariableGroup
, it can be done in the following way:
CD pipeline
variables:
- group: MyVariableGroup
The variable that was previously set in the CI pipeline, will then be available in the CD pipeline.