代码之家  ›  专栏  ›  技术社区  ›  Richard Barraclough

带有通配符文件名的Azure管道复制文件

  •  0
  • Richard Barraclough  · 技术社区  · 4 年前

    这很管用

    - 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)
    ...
    

    为什么复制的东西会下降到我不感兴趣的子目录中?

    0 回复  |  直到 4 年前
        1
  •  0
  •   Leo Liu    4 年前

    带有通配符文件名的Azure管道复制文件

    如果不想浪费时间搜索子目录,可以使用 !**\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 ,如果它不适用于您,您可能需要检查文件的路径 设置。sql :

    enter image description here