Search code examples
azure-devopsazure-pipelinestokenize

Get list of tokenized files and deploy them


My google foo is failing me. We have a system compiled of 10's of thousands of files. hundreds of which we have an environment token {#...#} in them. most all are PL/SQL, so we deploy individual files not a built package. when we refresh our Non-Prod environments from production we need to redeploy all those tokenized files.

We are using the Replace tokens step in AzureDevops Release Pipelines. but it deploys the files that have changes within the git commit hashes selected.

Is there a way to pragmatically get all those tokenized files. changed and not, and deploy only those via the AzureDevops pipelines?


Solution

  • Is there a way to pragmatically get all those tokenized files. changed and not

    If you want to replace all tokenized files(changed and not), you can specify the parameter Target files to **\* in Replace Token task. It will search all files in your root directory and replace the token with the variable you define. enter image description here Result:

    enter image description here

    If there is any misunderstanding, please feel free to let me know.

    UPDATE

    If you want to tell pipeline to deploy only all of those tokenized files(changed and not),you can use powershell task and Replace token task to achieve it.

    1.Powershell Task

    The script is aim to search specific word or pattern in the all source code files. You can get all list of tokenize files and copy them to a temp folder.

     $found_files = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Recurse | Select-String -Pattern "your token word" | Select path;
    
     if($found_files){
       foreach ($f in $found_files){ 
        Copy-Item $f.path -Destination  "$(System.DefaultWorkingDirectory)\temp";
       }
     }
    
    

    2 Replace token

    It will replace token variable in the temp folder that including all those tokenized files.

    Now those tokenized files are in $(System.DefaultWorkingDirectory)\temp folder, you can select temp folder to deploy. enter image description here

    Hope it can help.