An Azure DevOps Extension for running Azure Resource Manager Template Tool Kit tests as part of your build or release pipeline.
This extension works on Windows and Linux build agents, so long as PowerShell core is present
The ARM Template Tool Kit is a new static code analyser for ARM templates created by Microsoft. It's an open-source PowerShell library that you can use to validate your templates against a series of test cases. These test cases are generic and designed to validate that your templates are following best practice, a little like the PowerShell PSScriptAnalyzer tool. The ARM TTK tests for things like:
For full details of the ARM TTK visit it's Git repository
This extension provides an easy way to run the ARM TTK tests against your templates within Azure DevOps. You could run these tests when you update your template repository, create a pull request against your template repositor or when you are looking to run your templtes to create infrastructure.
This extension expects two parameters
You can also provide these optional parameters:
az bicep install
command needs to be run prior to running tests, the extension will not install it for you. If you leave this set to false the extension will install Bicep.exe for you if needed.
- task: RunARMTTKTestsXPlat@1
inputs:
templatelocation: '$(System.DefaultWorkingDirectory)\templates'
resultLocation: '$(System.DefaultWorkingDirectory)\results'
includeTests: 'VM Images Should Use Latest Version,Resources Should Have Location'
skipTests: 'VM Images Should Use Latest Version,Resources Should Have Location'
mainTemplates: 'template1.json, template2.json'
allTemplatesMain: false
cliOutputResults: true
recurse: true
ignoreExitCode: false
usePSCore: true
azureServiceConnection: serviceConnectionName
useAzBicep: false
This extension does not publish the tests results to show in the Azure DevOps UI its self, you need to use the "Publish Test Results" extension to read the XML files and publish the results so you can see a test report in the UI. All you need to do is pass the results folder path with a filter looking for armttk results files, e.g:
- task: PublishTestResults@2
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: '$(System.DefaultWorkingDirectory)\results\*-armttk.xml'
condition: always()
If any of your tests fail, the RunARMTTKTests task will also fail. To ensure that you always publish your test results make sure you use the condition: always()
setting so this always runs.
Once you do this, Azure DevOps will show the results of your tests in the build.
This extension uses the MIT License