【发布时间】:2021-06-10 05:23:51
【问题描述】:
如何在 azure cli 中使用通配符?
我希望在我的 azure cli 脚本中包含以下内容:
$(System.DefaultWorkingDirectory)/**/*.zip
现在,我的 azure cli 中有以下路径:
$artifactfolder = '$(System.DefaultWorkingDirectory)' + '\_TestApi\drop\TestApi.zip'
那么我怎样才能使用带有通配符的方法呢?
这是我的 CLI 脚本:
$resourceGroup = "Test"
$appServicePlan = "brajzoreappserviceplan"
$appServiceName = "brajzoreappservice2"
$artifactFolder = Get-ChildItem -Path "$(System.DefaultWorkingDirectory)" + "\**\*.zip"
az webapp deployment source config-zip --resource-group $resourceGroup --name $appServiceName --src $artifactfolder
运行脚本时出现以下错误:
2021-03-12T07:47:10.5624737Z Get-ChildItem : A positional parameter cannot be found that accepts argument '\**\*.zip'.
2021-03-12T07:47:10.5627860Z At D:\a\_temp\azureclitaskscript1615535200528_inlinescript.ps1:9 char:19
2021-03-12T07:47:10.5629171Z + $artifactFolder = Get-ChildItem -Path "D:\a\r1\a" + "\**\*.zip"
2021-03-12T07:47:10.5630150Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-03-12T07:47:10.5630966Z + CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParentContainsErrorRecordException
2021-03-12T07:47:10.5632192Z + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
2021-03-12T07:47:10.5633181Z
2021-03-12T07:47:10.6016965Z ##[error]Script failed with exit code: 1
【问题讨论】:
-
请分享您的 CLI 脚本和您想要达到的目的。
-
@CharlesXu:检查我更新的问题。
-
试试
$artifactFolder = Get-ChildItem -Path "$(System.DefaultWorkingDirectory)\*\*\*.zip"。
标签: azure powershell azure-devops azure-cli