我正在使用以下 yaml 文件,其中声明了项目设置中的所有变量。 AZ登录命令运行失败。当我将变量替换为实际值时,它就能够运行了。知道为什么没有从项目设置中选取变量值吗?
variables:
DEFAULT_RG:
description: "Default resource group to deploy the resources for testing"
value: "newgrp"
DEFAULT_LOCATION:
description: "Default location of the testing resource group"
value: "East US"
default:
image: mcr.microsoft.com/azure-cli
before_script:
- az login --service-principal --username $SP_ID --password $SP_SECRET --tenant $TENANT_ID
- az account set --subscription $SUBSCRIPTION_ID
- set -euo pipefail
stages:
- deploy
deploy automation account and tie it with UAMI:
stage: deploy
script:
- New-AzAutomationAccount -Location $Location -Name $automationccount -ResourceGroupName $ResourceGroup
- Set-AzAutomationAccount -ResourceGroupName $ResourceGroup -Name $automationccount -AssignUserIdentity "/subscriptions/$SUBSCRIPTION_ID/resourcegroups/$resourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/$userAssignedOne"
最佳答案
嗯,我解决了这个问题。我已将所有变量用作“ protected ”,这意味着我只能在 protected 分支上使用这些变量!
关于azure - Gitlab CI 无法从项目设置中选择变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72262714/