列出 Azure 管道中文件夹中的所有文件
Listing all files in a folder from an Azure pipeline
我正在尝试通过执行如下所示的操作为构建目录中的每个文件执行命令:
- task: CmdLine@2
displayName: 'List files'
inputs:
script: |
for %f in ( "$(Build.ArtifactStagingDirectory)\*" ) do @echo %f
不过我收到以下错误,
==============================================================================
Generating script.
Script contents:
for %f in ( "C:\Users\tester\my_agent\_work\a\*" ) do @echo %f
========================== Starting Command Output ===========================
"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\Users\tester\my_agent\_work\_tempa83c3a7-8a9e-4edf-aa36-e4e14d1ee5c7.cmd""
\Users\tester\my_agent\_work\a\*" ) do @echo f was unexpected at this time.
##[error]Cmd.exe exited with code '255'.
Finishing: List files
如何更正我的上述任务,使其按预期工作?
你可以试试:
- task: CmdLine@2
displayName: 'List files'
inputs:
script: |
dir /a-D /S /B
workingDirectory: '$(Build.ArtifactStagingDirectory)'
在批处理脚本中,您必须 将 %:
加倍
示例如下:
- task: CmdLine@2
displayName: 'List files'
inputs:
script: |
for %%f in ( "$(Build.ArtifactStagingDirectory)\*" ) do @echo %%f
我正在尝试通过执行如下所示的操作为构建目录中的每个文件执行命令:
- task: CmdLine@2
displayName: 'List files'
inputs:
script: |
for %f in ( "$(Build.ArtifactStagingDirectory)\*" ) do @echo %f
不过我收到以下错误,
==============================================================================
Generating script.
Script contents:
for %f in ( "C:\Users\tester\my_agent\_work\a\*" ) do @echo %f
========================== Starting Command Output ===========================
"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\Users\tester\my_agent\_work\_tempa83c3a7-8a9e-4edf-aa36-e4e14d1ee5c7.cmd""
\Users\tester\my_agent\_work\a\*" ) do @echo f was unexpected at this time.
##[error]Cmd.exe exited with code '255'.
Finishing: List files
如何更正我的上述任务,使其按预期工作?
你可以试试:
- task: CmdLine@2
displayName: 'List files'
inputs:
script: |
dir /a-D /S /B
workingDirectory: '$(Build.ArtifactStagingDirectory)'
在批处理脚本中,您必须 将 %:
加倍示例如下:
- task: CmdLine@2
displayName: 'List files'
inputs:
script: |
for %%f in ( "$(Build.ArtifactStagingDirectory)\*" ) do @echo %%f