0

我正在尝试通过执行如下所示的操作来为构建目录中的每个文件执行命令:

- 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\1\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\_temp\7a83c3a7-8a9e-4edf-aa36-e4e14d1ee5c7.cmd""
\Users\tester\my_agent\_work\1\a\*" ) do @echo f was unexpected at this time.
##[error]Cmd.exe exited with code '255'.
Finishing: List files

如何更正上面的任务以使其按预期工作?

4

2 回答 2

0

你可以试试:

- task: CmdLine@2
  displayName: 'List files'
  inputs:
    script: |
      dir /a-D /S /B
    workingDirectory: '$(Build.ArtifactStagingDirectory)'
于 2021-07-23T13:12:12.180 回答
0

在批处理脚本中,您必须将 % 加倍

这是示例:

- task: CmdLine@2
  displayName: 'List files'
  inputs:
    script: |
      for %%f in ( "$(Build.ArtifactStagingDirectory)\*" ) do @echo %%f
于 2021-07-28T07:31:21.403 回答