forked from Azure/PSRule.Rules.Azure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yaml
42 lines (35 loc) · 1.64 KB
/
azure-pipelines.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#
# PSRule with Azure Pipelines
#
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
# Install PSRule.Rules.Azure from the PowerShell Gallery
- task: ps-rule-install@2
inputs:
module: PSRule.Rules.Azure # Install PSRule.Rules.Azure from the PowerShell Gallery.
# Export resource data from parameter files within the current working directory.
- powershell: Get-AzRuleTemplateLink | Export-AzRuleTemplateData -OutputPath out/templates/;
displayName: 'Export template data'
# Run analysis from JSON files using the `PSRule.Rules.Azure` module and custom rules from `.ps-rule/`.
- task: ps-rule-assert@2
inputs:
inputType: inputPath
inputPath: 'out/templates/*.json' # Read exported resource data from 'out/templates/'.
modules: 'PSRule.Rules.Azure' # Analyze objects using the rules within the PSRule.Rules.Azure PowerShell module.
# Optionally, also analyze objects using custom rules from '.ps-rule/'.
source: '.ps-rule/'
# Optionally, save results to an NUnit report.
outputFormat: NUnit3
outputPath: reports/ps-rule-resources.xml
# Publish NUnit report as test results
- task: PublishTestResults@2
displayName: 'Publish PSRule results'
inputs:
testRunTitle: 'PSRule' # The title to use for the test run.
testRunner: NUnit # Import report using the NUnit format.
testResultsFiles: 'reports/ps-rule-*.xml' # Use previously saved NUnit reports.
mergeTestResults: true # Merge multiple reports.
condition: succeededOrFailed() # Run this task if previous steps succeeded of failed.