Cri*_* E. 13 azure-devops azure-pipelines
我正在努力描绘 azure 管道的文件夹结构。我知道有一些隐式目录,例如:
这两个文件夹都是池中可用的特定构建代理上的文件夹。
有没有办法查看文件夹结构并更好地了解事物的布局?
Dre*_*ost 23
另一种选择是将其添加到 YAML 管道中:
- powershell: Get-ChildItem -Path 'Insert root path' -recurse
Run Code Online (Sandbox Code Playgroud)
它看起来像:
Get-ChildItem -Path C:\Test\*.txt -Recurse -Force
Directory: C:\Test\Logs\Adirectory
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2/12/2019 16:16 20 Afile4.txt
-a-h-- 2/12/2019 15:52 22 hiddenfile.txt
-a---- 2/13/2019 13:26 20 LogFile4.txt
Directory: C:\Test\Logs\Backup
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2/12/2019 16:16 20 ATextFile.txt
-a---- 2/12/2019 15:50 20 LogFile3.txt
Directory: C:\Test\Logs
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2/12/2019 16:16 20 Afile.txt
-a-h-- 2/12/2019 15:52 22 hiddenfile.txt
-a---- 2/13/2019 13:26 20 LogFile1.txt
Directory: C:\Test
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2/13/2019 08:55 26 anotherfile.txt
-a---- 2/12/2019 15:40 118014 Command.txt
-a-h-- 2/12/2019 15:52 22 hiddenfile.txt
-ar--- 2/12/2019 14:31 27 ReadOnlyFile.txt
Run Code Online (Sandbox Code Playgroud)
如果您需要更多信息,请参阅有关 Get-ChildItem 命令的文档
Lan*_*SFT 19
您可以使用CMD 任务在 Microsoft 托管的 Windows 代理中调用tree 命令来获取文件夹结构。
我的脚本:
echo "Structure of work folder of this pipeline:"
tree $(Agent.WorkFolder)\1 /f
echo "Build.ArtifactStagingDirectory:"
echo "$(Build.ArtifactStagingDirectory)"
echo "Build.BinariesDirectory:"
echo "$(Build.BinariesDirectory)"
echo "Build.SourcesDirectory:"
echo "$(Build.SourcesDirectory)"
Run Code Online (Sandbox Code Playgroud)
结果:
$(Agent.WorkFolder)代表当前代理$(Agent.WorkFolder)\1的工作文件夹,代表当前管道的工作文件夹。(通常第一个管道会放入$(Agent.WorkFolder)\1,第二个$(Agent.WorkFolder)\2......)
所以很明显,对于一个管道运行,它默认有四个文件夹:a(工件文件夹)、b(二进制文件夹)、s(源文件夹)和 TestResults(测试结果文件夹)。该s文件夹是下载源代码文件的位置。对于构建流水线:$(Build.SourcesDirectory),$(Build.Repository.LocalPath)并$(System.DefaultWorkingDirectory)表示相同的文件夹中。更多细节参见预定义变量。
Mik*_*ike 18
@LoLance 的答案非常适合 Windows 代理。对于 Linux 代理,语法略有不同(反转斜杠,并删除 /f 标志):
- task: CmdLine@2
inputs:
script: |
echo "Structure of work folder of this pipeline:"
tree $(Agent.WorkFolder)/1
echo "Build.ArtifactStagingDirectory:"
echo "$(Build.ArtifactStagingDirectory)"
echo "Build.BinariesDirectory:"
echo "$(Build.BinariesDirectory)"
echo "Build.SourcesDirectory:"
echo "$(Build.SourcesDirectory)"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9688 次 |
| 最近记录: |