Azure yml-在$(System.DefaultWorkingDirectory)中递归搜索文件夹

Azure yml-在$(System.DefaultWorkingDirectory)中递归搜索文件夹,azure,azure-devops,azure-yaml-pipelines,Azure,Azure Devops,Azure Yaml Pipelines,在azure.yml脚本中,我希望递归搜索以_test结尾的文件夹,该文件夹位于$(System.DefaultWorkingDirectory) 到目前为止,我已经试过了 [ -d "**/$(System.DefaultWorkingDirectory)/**/?(*_test)" ] 及 然而,这两种模式都不起作用 是否可以递归搜索$(System.DefaultWorkingDirectory)中的文件夹 您能推荐一种合适的方法来搜索以_test结尾的文件夹吗 谢谢

在azure.yml脚本中,我希望递归搜索以_test结尾的文件夹,该文件夹位于$(System.DefaultWorkingDirectory)

到目前为止,我已经试过了

[ -d "**/$(System.DefaultWorkingDirectory)/**/?(*_test)" ]

然而,这两种模式都不起作用

是否可以递归搜索$(System.DefaultWorkingDirectory)中的文件夹

您能推荐一种合适的方法来搜索以_test结尾的文件夹吗


谢谢大家!

如果要在azure.yml脚本中搜索以_test结尾的$(System.DefaultWorkingDirectory)文件夹,请尝试以下yaml示例

pool:
  vmImage: ubuntu-latest

steps:
- pwsh: Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Recurse -Directory -Name -Include "**_test"
更新> 已安装PowerShell工具,因此PowerShell在其中可用。 如果您更喜欢使用Bash脚本,此命令
find$(System.DefaultWorkingDirectory)-name“***\u test”-type d
将输出目标文件夹路径

请注意,可能有多个文件夹,您可以使用以下脚本将结果分配给变量

- bash: |
    result=$(find $(System.DefaultWorkingDirectory) -name "**_test" -type d)
    echo "$result"
或者,您可以通过引用此函数将结果分配给数组

-bash:|

readarray-d“”结果\u数组<谢谢您的建议!Powershell在托管代理中不可用。因此,我得到了“command not found”错误。我计划使用bash命令“find”来验证_测试文件夹是否存在。我尝试了下面的方法,但它似乎无法工作UNIT_TEST=$(find.-name“*_TEST”)echo“##vso[task.setvariable=UNIT_TEST]$UNIT_TEST”请告诉我如何在变量中获得bash的输出。谢谢!嗨,亚穆纳,我已经更新了我的答案供你参考。请注意,结果不能通过
echo“##vso[task.setvariable=UNIT_TEST]$UNIT_TEST”
分配给变量,因为它们是不同的数据结构。您可以尝试遍历数组以将其元素分配给不同的变量。Hi@Edward Han MSFT,result=$(find$(System.DefaultWorkingDirectory)-name“**u test”-type d)对我来说很有效。谢谢你的支持!嗨,亚穆纳,更新的答案有用吗?请检查一下,并告诉我结果。谢谢
- bash: |
    result=$(find $(System.DefaultWorkingDirectory) -name "**_test" -type d)
    echo "$result"
- bash: |
    readarray -d '' result_array < <(find $(System.DefaultWorkingDirectory) -name "**_test" -type d)
    echo "$result_array"