我一直在尝试查找有关如何在 Azure DevOps 中对变量组进行版本控制(或者是否对它们进行版本控制)的一些信息。
我的“问题”是如果我们遇到以下情况怎么办:
我们有一个发布管道,它有一个链接变量组,其中包含发布所依赖的一组变量。
在我们第一次运行发布管道(第 1 版)期间,我们部署了我们的应用程序,并使用变量组变量来配置应用程序。
在我们的第一个版本发布后,一切正常,几周过去了,我们决定对变量组进行一些更改。例如,我们可能会更改变量的名称或更改值。现在我们已准备好发布下一个版本(第 2 版)。
我们运行我们的版本,但只是发现有些东西坏了,应用程序不再工作了..所以我们想快速回滚到前一个阶段(到版本 1),所以我们只是简单地“重新-发布/重新运行“我们为发布 1 所做的发布......但是......因为我们已经更改了我们的变量组变量,这会导致我们使用新更新的变量进行发布,还是 Azure DevOps 以某种方式存储/“snapshot"版本第一次运行时变量组的阶段?
最佳答案
Azure DevOps 中的变量组不是版本(还...)。因此,如果您更新变量组,您可以知道之前发生了什么。
但是,作为一种解决方法,您可以创建一个 Gir 存储库来保存数据并使用自动管道更新他:
trigger: none
schedules:
- cron: "*/15 14-21 * * Mon-Fri"
displayName: Every 15 min M-F 9am-4:45pm (UTC-05:00)
branches:
include:
- master
always: true
- cron: "0 22 * * Mon-Fri"
displayName: M-F 5pm (UTC-05:00)
branches:
include:
- master
always: true
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
persistCredentials: true
clean: true
# Updating the python version available on the linux agent
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
architecture: 'x64'
# Updating pip to latest
- script: python -m pip install --upgrade pip
displayName: 'Upgrade pip'
# Updating to latest Azure CLI version.
- script: pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge
displayName: 'Upgrade Azure CLI'
- script: az --version
displayName: 'Show Azure CLI version'
- script: az extension add -n azure-devops
displayName: 'Install Azure DevOps Extension'
- script: echo ${AZURE_DEVOPS_CLI_PAT} | az devops login
env:
AZURE_DEVOPS_CLI_PAT: $(System.AccessToken)
displayName: 'Login Azure DevOps Extension'
- script: az devops configure --defaults organization=$(System.TeamFoundationCollectionUri) project="$(System.TeamProject)"
displayName: 'Set default Azure DevOps organization and project'
- pwsh: |
# Checkout the source branch
git checkout $(Build.SourceBranchName)
# Get all variable groups
$groups = ConvertFrom-Json "$(az pipelines variable-group list)"
$groups | foreach {
$groupName = $_.name
# Prepend VariableGroups folder name
$filePath = Join-Path "VariableGroups" "$groupName.json"
# Save the variable group to a file
ConvertTo-Json $_ | New-Item $filePath -Force
# Use the last modified user's name and email
git config user.email $_.modifiedBy.uniqueName
git config user.name $_.modifiedBy.displayName
# Stage the file
git add $filePath
# Commit
git commit -m "Variable group $groupName updates"
}
# Push all changes
git push origin
displayName: 'Save variable groups'
详细解说你好here .
关于variables - (如何)在 Azure DevOps 中对变量组进行版本控制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62893079/