Azure cli 运行 批量 azure devops 错误
Azure cli running batch azure devops error
在多行中使用 azure cli 时出现此错误。单个命令运行良好。
The term 'call' is not recognized as the name of a cmdlet, function, script file, or operable program. Check...
我刚刚创建了一个新版本并复制了该行为。您实际上在 Script Type
字段中选择了 Powershell
。将其更改为 Batch
,它将按预期工作。
编辑
我想我也会分享如何 运行 从您的 repo 批处理脚本,如果开发人员在每一行的开头都有 call
语句,请不要担心。我只是在我的构建中有一个标准化脚本,它在发布工件
之前注入 call
$Deploy_File = Get-Item "Azure-Commands.cmd"
$Deploy_File_Script = $Deploy_File | Get-Content
$Deploy_File_Script_Mod = @()
##Standardise commands for Azure CLI Deployment task
# Loop through Commands
foreach ($Command in $Deploy_File_Script) {
#Insert "CALL" before each azure command
if ($Command -like "az *") {
$Command = "call " + $Command
}
# Build Modified script array
$Deploy_File_Script_Mod += "$Command"
}
#Save to file
$Deploy_File | Set-Content -Value $Deploy_File_Script_Mod
#Output modified commands in file
$Deploy_File | Get-Content
现在您可以从上面的任务中调用标准化的部署文件
在多行中使用 azure cli 时出现此错误。单个命令运行良好。
The term 'call' is not recognized as the name of a cmdlet, function, script file, or operable program. Check...
我刚刚创建了一个新版本并复制了该行为。您实际上在 Script Type
字段中选择了 Powershell
。将其更改为 Batch
,它将按预期工作。
编辑
我想我也会分享如何 运行 从您的 repo 批处理脚本,如果开发人员在每一行的开头都有 call
语句,请不要担心。我只是在我的构建中有一个标准化脚本,它在发布工件
call
$Deploy_File = Get-Item "Azure-Commands.cmd"
$Deploy_File_Script = $Deploy_File | Get-Content
$Deploy_File_Script_Mod = @()
##Standardise commands for Azure CLI Deployment task
# Loop through Commands
foreach ($Command in $Deploy_File_Script) {
#Insert "CALL" before each azure command
if ($Command -like "az *") {
$Command = "call " + $Command
}
# Build Modified script array
$Deploy_File_Script_Mod += "$Command"
}
#Save to file
$Deploy_File | Set-Content -Value $Deploy_File_Script_Mod
#Output modified commands in file
$Deploy_File | Get-Content
现在您可以从上面的任务中调用标准化的部署文件