小编use*_*243的帖子

lower() 函数似乎在 Azure DevOps YAML 管道中不起作用

我尝试在 YAML 模板中使用 lower() 函数,但不理解其行为。我有一个名为 Infra.Environment.ShortName 的变量组,其值为“Dev”。在我的 YAML 模板中,我从变量组中定义了一个变量:

  variables:
  - name: environmentShortName
    value: $(Infra.Environment.ShortName)
Run Code Online (Sandbox Code Playgroud)

在任务中,我引用这个变量:

- task: AzureResourceGroupDeployment@2
  displayName: 'Deploy Storage Account'
  inputs:
    azureSubscription: ${{ parameters.subscription }}
    resourceGroupName: mst-${{ lower(variables.environmentShortName) }}-infra
    location: '$(Infra.Environment.Region.Primary)'
    csmFile: '$(Pipeline.Workspace)/$(Build.DefinitionName)/Resources/infra-storageAccount.json'
    csmParametersFile: '$(Pipeline.Workspace)/$(Build.DefinitionName)/Resources/infra-storageAccount.parameters.json'
    deploymentOutputs: ArmOutputs
Run Code Online (Sandbox Code Playgroud)

我尝试过不同的表达式,但不明白为什么我无法将变量组值转换为小写:

resourceGroupName: mst-${{ lower(variables.environmentShortName) }}-infra
Run Code Online (Sandbox Code Playgroud)

=> mst-Dev-infra(较低的似乎不起作用)

resourceGroupName: ${{ format('mst-{0}-infra', lower(variables.environmentShortName)) }}
Run Code Online (Sandbox Code Playgroud)

=> mst-Dev-infra (格式有效,但 lower 无效)

resourceGroupName: $[format('mst-{0}-infra', lower(variables.environmentShortName))]
Run Code Online (Sandbox Code Playgroud)

=> $[format('mst-{0}-infra', lower(variables.environmentShortName))] (表达式未计算)

resourceGroupName: mst-${{ lower(variables['Infra.Environment.ShortName']) }}-infra
Run Code Online (Sandbox Code Playgroud)

=> mst--infra(空值)

resourceGroupName: mst-${{ lower('Dev') }}-infra
Run Code Online (Sandbox Code Playgroud)

=> mst-dev-infra(较低的作品使用恒定值)

azure-devops azure-pipelines-yaml

5
推荐指数
2
解决办法
8391
查看次数

标签 统计

azure-devops ×1

azure-pipelines-yaml ×1