azure - Azure yml - 在 $(System.DefaultWorkingDirectory) 中递归搜索文件夹
问题描述
在 azure.yml 脚本中,我想递归搜索以$(System.DefaultWorkingDirectory)中的 _test 结尾的文件夹
到目前为止,尝试过
[ -d "**/$(System.DefaultWorkingDirectory)/**/?(*_test)" ]
和
[ -d "$(System.DefaultWorkingDirectory)/**/*_test" ]
但是,这两种模式都不起作用。
是否可以递归搜索 $(System.DefaultWorkingDirectory) 中的文件夹?
您能否建议一种合适的方法来搜索$(System.DefaultWorkingDirectory)中以 _test 结尾的文件夹?
谢谢!
解决方案
如果要在 azure.yml 脚本中搜索 $(System.DefaultWorkingDirectory) 中以 _test 结尾的文件夹,请尝试以下 yaml 示例。
pool:
vmImage: ubuntu-latest
steps:
- pwsh: Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Recurse -Directory -Name -Include "**_test"
更新>>
Microsoft 托管的 Ubuntu 代理已安装 PowerShell 工具,因此可以使用 PowerShell。如果您更喜欢使用 Bash 脚本,此命令find $(System.DefaultWorkingDirectory) -name "**_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"
推荐阅读
- linux - “错误:EACCES:权限被拒绝” - 在 AWS EC2 实例上运行 Meteor 应用程序 (OHIF)
- python - from django.db.models import Q, Count, F, JSONField ImportError: cannot import name 'JSONField'
- laravel - 在 Livewire 中单击之前如何防止使用参数
- c - c时钟()在不同的操作系统
- r - 如何删除包含某些文本的 tibble 行?
- apache-flink - Flink:使用 CSV 文件的事件时间聚合
- flutter - 单击单选按钮时如何更改容器
- python - 即使在执行程序后,Postgresql 数据库上的连接仍处于活动状态
- cypress - 赛普拉斯:如何通过检查 URL 有条件地跳过测试
- java - 解决两个插件之间的循环依赖问题