0

I am running Unit Tests using ARM-TTK in Azure Devops and i have some selective unit tests that i would like to run from a desired location. The two location where i have my .JSON files are : ARM_Templates/IaaS and ARM_Templates/PaaS. I have other folders also that are present inside ARM_Templates parent folder but i don't want to include them in the test. So one of my task in the YAML pipeline is provided below :

- task: PowerShell@2
  displayName: 'Run deploymentTemplate tests from ARM Template Tester Toolkit'
  inputs:
    condition: always()
    targetType: 'inline'
    script: |
      cd D:\a\1\s\arm-template-toolkit\arm-ttk
      Import-Module ./arm-ttk.psd1
      get-childitem $(System.DefaultWorkingDirectory)/ArmTemplates.Templates/*.json | Test-AzTemplate  -test "Resources Should Have Location","Location Should Not Be Hardcoded", "apiversions-should-be-recent"
    pwsh: true
    workingDirectory: '$(System.DefaultWorkingDirectory)/arm-template-toolkit/arm-ttk'

So how to specify the two different locations in the get-childitem cmdlet in the task so that ARM-TTK picks up the *.json files from both the folder locations

Pallab
  • 1,915
  • 2
  • 19
  • 46

1 Answers1

0

In 'Get-ChildItem' you can pass multiple paths as follow Get-ChildItem –path c:\fso,c:\music. Please check aslo this answer. So in your case it would be

- task: PowerShell@2
  displayName: 'Run deploymentTemplate tests from ARM Template Tester Toolkit'
  inputs:
    condition: always()
    targetType: 'inline'
    script: |
      cd D:\a\1\s\arm-template-toolkit\arm-ttk
      Import-Module ./arm-ttk.psd1
      get-childitem $(System.DefaultWorkingDirectory)/ARM_Templates/IaaS/*.json,$(System.DefaultWorkingDirectory)/ARM_Templates/PaaS/*.json | Test-AzTemplate  -test "Resources Should Have Location","Location Should Not Be Hardcoded", "apiversions-should-be-recent"
    pwsh: true
    workingDirectory: '$(System.DefaultWorkingDirectory)/arm-template-toolkit/arm-ttk'
Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107