azure-devops - 带有通配符文件名的 Azure 管道 CopyFiles
问题描述
这有效
- task: CopyFiles@2
condition: eq(variables.publishDeployables, true)
displayName: 'Add README.md to output'
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: 'README.MD'
targetFolder: '$(Build.ArtifactStagingDirectory)'
但是这个:
- task: CopyFiles@2
condition: eq(variables.publishDeployables, true)
displayName: 'Add SQL to output'
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: 'Setup*.sql'
targetFolder: '$(Build.ArtifactStagingDirectory)
- 需要很长时间搜索所有子目录,并且
- 匹配
SetupSecurity.sql
但不匹配Setup.sql
。
这是怎么回事?!
更新:日志输出
##[debug]Evaluating condition for step: 'Add SQL to output'
##[debug]Evaluating: eq(variables['publishDeployables'], True)
##[debug]Evaluating eq:
##[debug]..Evaluating indexer:
##[debug]....Evaluating variables:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'publishDeployables'
##[debug]..=> 'True'
##[debug]..Evaluating Boolean:
##[debug]..=> True
##[debug]..=> 'True'
##[debug]=> True
##[debug]Expanded: eq('True', True)
##[debug]Result: True
##[section]Starting: Add SQL to output
==============================================================================
Task : Copy files
Description : Copy files from a source folder to a target folder using patterns matching file paths (not folder paths)
Version : 2.151.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/copy-files
==============================================================================
##[debug]agent.workFolder=C:\agent\_work
##[debug]loading inputs and endpoints
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading INPUT_CLEANTARGETFOLDER
##[debug]loading INPUT_CONTENTS
##[debug]loading INPUT_FLATTENFOLDERS
##[debug]loading INPUT_OVERWRITE
##[debug]loading INPUT_PRESERVETIMESTAMP
##[debug]loading INPUT_SOURCEFOLDER
##[debug]loading INPUT_TARGETFOLDER
##[debug]loading SECRET_CHECKMARX_PASSWORD
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 12
##[debug]check path : C:\agent\_work\_tasks\CopyFiles_5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c\2.151.1\task.json
##[debug]set resource file to: C:\agent\_work\_tasks\CopyFiles_5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c\2.151.1\task.json
##[debug]system.culture=en-US
##[debug]Contents=Setup*.sql
##[debug]SourceFolder=C:\agent\_work\12\s
##[debug]check path : C:\agent\_work\12\s
##[debug]TargetFolder=C:\agent\_work\12\a
##[debug]CleanTargetFolder=false
##[debug]OverWrite=false
##[debug]flattenFolders=false
##[debug]preserveTimestamp=false
##[debug]findPath: 'C:\agent\_work\12\s'
##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
##[debug]findOptions.followSymbolicLinks: 'true'
##[debug] C:\agent\_work\12\s (directory)
##[debug] C:\agent\_work\12\s\.git (directory)
##[debug] C:\agent\_work\12\s\.git\config (file)
##[debug] C:\agent\_work\12\s\.git\description (file)
##[debug] C:\agent\_work\12\s\.git\FETCH_HEAD (file)
##[debug] C:\agent\_work\12\s\.git\HEAD (file)
##[debug] C:\agent\_work\12\s\.git\hooks (directory)
##[debug] C:\agent\_work\12\s\.git\hooks\applypatch-msg.sample (file)
...
为什么复制的东西会下降到我不感兴趣的子目录中?
解决方案
带有通配符文件名的 Azure 管道 CopyFiles
如果您不想浪费时间搜索子目录,可以使用以下命令排除子目录!**\TestSubfolder\Setup*.sql
:
- task: CopyFiles@2
condition: eq(variables.publishDeployables, true)
displayName: 'Add SQL to output'
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
Contents: |
Setup*.sql
!**\TestSubfolder\Setup*.sql
!**\TestSubfolder2\Setup*.sql
targetFolder: '$(Build.ArtifactStagingDirectory)
并且在我测试时,Setup*.sql
匹配文件Setup.sql
,如果它不适合你,你可能需要检查文件的路径Setup.sql
:</p>
推荐阅读
- javascript - 使用 javascript for 循环处理异步数组
- android - 将 LiveDataTestUtil 与 Kotest 一起使用
- python - 为什么我的 Python 多处理结果没有附加到回调上?
- google-sheets - Googlesheet 中的 importxml 函数
- python - 使用 python 对 .csv 文件中的列求和
- javascript - 如何检查数组中的每个元素以查看它是否存在于另一个数组中,并将第一个数组中的元素替换为其他元素?
- networkx - 有没有办法限制networkx上游节点深度搜索
- c++ - 我无法为列表 C++ 中的对象赋值
- python - 将格式不正确的字符串转换为字典?
- javascript - JavaScript 变量值不继续