AZ CLI 无法识别 Azure DevOps 参数
Azure DevOps Parameters not recognised by AZ CLI
我在将 Azure Pipeline YAML 中定义的参数传递到位于 bash 脚本中的 AZ Cli 时遇到问题。我在 Whosebug 上找到了以下解决方案,但它似乎不起作用:
这是我的 YAML 文件:
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: AzureCLI@2
displayName: Azure CLI
inputs:
azureSubscription: templateresourceconnection
scriptType: bash
scriptPath: ./deployment.sh
arguments:
-resourceGrp 'TEST-RG'
-location 'westeurope'
我希望能够访问我的 deployment.sh 中的参数,但失败了:
#!/bin/bash
# Create Resource Group
az group create -n $(resourceGrp) -l $(location)
如果我不传递任何参数并对 deployment.sh 中的值进行硬编码,则一切正常。
任何想法可能导致此问题?我也试过使用大写字母,只是没有括号。
我收到以下错误消息
你知道我还能尝试什么来让它发挥作用吗?似乎文档不包含 az cli 的任何示例。只是如何定义参数而不是如何传递它们。
谢谢。
Do you have any idea what else I could try to make it work
您可以尝试使用 Environment variable。 bash 个脚本文件可以访问环境变量。
首先,您需要定义管道变量而不是任务参数。
variables:
- name: one
value: initialValue
这是我的例子:在Linux系统中使用。
az group create -n $RESOURCEGRP -l $LOCATION
注意:环境变量中所有字符需要大写
例如:resourceGrp -> $RESOURCEGRP
Yaml 示例:
variables:
- name: resourceGrp
value: TEST-RG
- name: location
value: westeurope
pool:
vmImage: 'ubuntu-latest'
steps:
- task: AzureCLI@2
displayName: 'Azure CLI deploy.sh'
inputs:
azureSubscription: kevin0209
scriptType: bash
scriptPath: ./deployment.sh
我在将 Azure Pipeline YAML 中定义的参数传递到位于 bash 脚本中的 AZ Cli 时遇到问题。我在 Whosebug 上找到了以下解决方案,但它似乎不起作用:
这是我的 YAML 文件:
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: AzureCLI@2
displayName: Azure CLI
inputs:
azureSubscription: templateresourceconnection
scriptType: bash
scriptPath: ./deployment.sh
arguments:
-resourceGrp 'TEST-RG'
-location 'westeurope'
我希望能够访问我的 deployment.sh 中的参数,但失败了:
#!/bin/bash
# Create Resource Group
az group create -n $(resourceGrp) -l $(location)
如果我不传递任何参数并对 deployment.sh 中的值进行硬编码,则一切正常。 任何想法可能导致此问题?我也试过使用大写字母,只是没有括号。
我收到以下错误消息
你知道我还能尝试什么来让它发挥作用吗?似乎文档不包含 az cli 的任何示例。只是如何定义参数而不是如何传递它们。
谢谢。
Do you have any idea what else I could try to make it work
您可以尝试使用 Environment variable。 bash 个脚本文件可以访问环境变量。
首先,您需要定义管道变量而不是任务参数。
variables:
- name: one
value: initialValue
这是我的例子:在Linux系统中使用。
az group create -n $RESOURCEGRP -l $LOCATION
注意:环境变量中所有字符需要大写
例如:resourceGrp -> $RESOURCEGRP
Yaml 示例:
variables:
- name: resourceGrp
value: TEST-RG
- name: location
value: westeurope
pool:
vmImage: 'ubuntu-latest'
steps:
- task: AzureCLI@2
displayName: 'Azure CLI deploy.sh'
inputs:
azureSubscription: kevin0209
scriptType: bash
scriptPath: ./deployment.sh