Azure Pipelines: Recursive file pattern produces 0 matches when searching for existing file

Viewed 72

Our pipeline includes the following task:

- task: RegexReplace@3
  displayName: "Replace token on $(resourceName)"
  condition: eq(variables['Agent.MachineName'], variables['TargetMachine'])
  inputs:
    inputSearchPattern: '**\*tokenized.config'
    findRegex: '\${ReplaceMe}'
    replaceRegex: 'Tokenization replacement successful'
    useUTF8: false
    useRAW: true     

The condition works just fine. But when we get to the part where it's trying find matching files, the build log always reports the following:

Starting: Replace token on MYTARGETSERVER

=========================================================================

Task : RegEx Find & Replace

Description : Find & Replace using Regular Expressions

Version : 3.3.11

Author : knom

Help : More Information

=========================================================================

Search Pattern is **\*tokenized.config

Found 0 files

Replacing ${ReplaceMe} with Tokenization replacement successful (ASCII, RAW)

Finishing: Replace token on MYTARGETSERVER

As shown, 0 files were matched, so our replacements don't occur. This happens no matter how we adjust the recursive file pattern.

We have tried:

  • **/*.tokenized.config
  • **\*.tokenized.config
  • **/*tokenized.config
  • **\*tokenized.config
  • $(Pipeline.Workspace)\drop\*.tokenized.config

My understanding is that the first pattern above should work and find our project.tokenized.config file. The file structure is as follows:

  • Solution Folder
    • Project Folder
      • Project.tokenized.config

What are we doing wrong in specifying the file pattern? Why doesn't recursive search seem to work here, producing 0 matches?

Note that we use the RegexReplace task because we want to modify specific settings on a per-server basis within our production environment. To our knowledge, the ReplaceTokens task doesn't support that.

ADDENDUM

The following tasks are further down in the same file, and they execute exactly as we expect them to, using the same file patterns.

- task: replacetokens@3
  displayName: "Replace tokens in tokenized configuration files"
  inputs:
    rootDirectory: "$(sitePath)"
    targetFiles: |
      **/*.tokenized.config => *.config
      **/*.tokenized.js => *.js
      **/*.tokenized.json => *.json
    encoding: "auto"
    writeBOM: true
    actionOnMissing: "warn"
    keepToken: true
    tokenPrefix: "${"
    tokenSuffix: "}"
    useLegacyPattern: false
    enableTelemetry: false

- task: DeleteFiles@1
  displayName: "Remove tokenized files"
  inputs:
    SourceFolder: $(sitePath)
    contents: |
      **/*.tokenized.config
      **/*.tokenized.js
      **/*.tokenized.json
0 Answers
Related