Azure yml - 在 $(System.DefaultWorkingDirectory) 中递归搜索文件夹
Azure yml - Search folder recursively in $(System.DefaultWorkingDirectory)
在azure.yml脚本中,我想在$(System.DefaultWorkingDirectory)
中递归搜索以_test结尾的文件夹
到目前为止,已试用
[ -d "**/$(System.DefaultWorkingDirectory)/**/?(*_test)" ]
和
[ -d "$(System.DefaultWorkingDirectory)/**/*_test" ]
但是,这两种模式都不起作用。
是否可以对 $(System.DefaultWorkingDirectory) 中的文件夹进行递归搜索?
能否建议一种合适的方法来搜索 $(System.DefaultWorkingDirectory)?
中以 _test 结尾的文件夹
谢谢!
如果您想在 azure.yml 脚本中搜索以 _test in $(System.DefaultWorkingDirectory) 结尾的文件夹,请尝试以下 yaml 示例。
pool:
vmImage: ubuntu-latest
steps:
- pwsh: Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Recurse -Directory -Name -Include "**_test"
更新>>
Microsoft-hosted Ubuntu agent 已安装 PowerShell 工具,因此其中包含 PowerShell。
如果您更喜欢使用 Bash 脚本,此命令 find $(System.DefaultWorkingDirectory) -name "**_test" -type d
将输出目标文件夹路径。
请注意,可能有多个文件夹,您可以使用以下脚本将结果分配给变量。
- bash: |
result=$(find $(System.DefaultWorkingDirectory) -name "**_test" -type d)
echo "$result"
或者你可以通过引用这个 thread.
将结果分配给数组
- bash: |
readarray -d '' result_array < <(find $(System.DefaultWorkingDirectory) -name "**_test" -type d)
echo "$result_array"
在azure.yml脚本中,我想在$(System.DefaultWorkingDirectory)
中递归搜索以_test结尾的文件夹到目前为止,已试用
[ -d "**/$(System.DefaultWorkingDirectory)/**/?(*_test)" ]
和
[ -d "$(System.DefaultWorkingDirectory)/**/*_test" ]
但是,这两种模式都不起作用。
是否可以对 $(System.DefaultWorkingDirectory) 中的文件夹进行递归搜索?
能否建议一种合适的方法来搜索 $(System.DefaultWorkingDirectory)?
中以 _test 结尾的文件夹谢谢!
如果您想在 azure.yml 脚本中搜索以 _test in $(System.DefaultWorkingDirectory) 结尾的文件夹,请尝试以下 yaml 示例。
pool:
vmImage: ubuntu-latest
steps:
- pwsh: Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Recurse -Directory -Name -Include "**_test"
更新>>
Microsoft-hosted Ubuntu agent 已安装 PowerShell 工具,因此其中包含 PowerShell。
如果您更喜欢使用 Bash 脚本,此命令 find $(System.DefaultWorkingDirectory) -name "**_test" -type d
将输出目标文件夹路径。
请注意,可能有多个文件夹,您可以使用以下脚本将结果分配给变量。
- bash: |
result=$(find $(System.DefaultWorkingDirectory) -name "**_test" -type d)
echo "$result"
或者你可以通过引用这个 thread.
将结果分配给数组- bash: |
readarray -d '' result_array < <(find $(System.DefaultWorkingDirectory) -name "**_test" -type d)
echo "$result_array"