-
Notifications
You must be signed in to change notification settings - Fork 29
/
tflint-pipeline.yml
61 lines (54 loc) · 2.33 KB
/
tflint-pipeline.yml
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
trigger: none
pr: none
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: QualityCheckStage
displayName: Quality Check Stage
jobs:
- job: TFLintJob
displayName: Run TFLint Scan
steps:
# TFLint is a framework that finds possible errors (like illegal instance types) for major cloud providers (AWS/Azure/GCP),
# warn about deprecated syntax, unused declarations, and enforce best practices, naming conventions.
- script: |
mkdir TFLintReport
docker pull ghcr.io/terraform-linters/tflint-bundle:latest
docker run \
--rm \
--volume $(System.DefaultWorkingDirectory)/Infrastructure-Source-Code/terraform:/data \
-t ghcr.io/terraform-linters/tflint-bundle \
--module \
--format junit > $(System.DefaultWorkingDirectory)/TFLintReport/TFLint-Report.xml
docker run \
--rm \
--volume $(System.DefaultWorkingDirectory)/Infrastructure-Source-Code/terraform:/data \
-t ghcr.io/terraform-linters/tflint-bundle \
--module
displayName: 'TFLint Static Code Analysis'
name: TFLintScan
condition: always()
# Publish the TFLint report as an artifact to Azure Pipelines
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: TFLint Report'
condition: succeededOrFailed()
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/TFLintReport'
ArtifactName: TFLintReport
# Publish the results of the TFLint analysis as Test Results to the pipeline
- task: PublishTestResults@2
displayName: Publish TFLint Test Results
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit' # Options JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: '**/*TFLint-Report.xml'
searchFolder: '$(System.DefaultWorkingDirectory)/TFLintReport'
mergeTestResults: false
testRunTitle: TFLint Scan
failTaskOnFailedTests: false
publishRunAttachments: true
# Clean up any of the containers / images that were used for quality checks
- bash: |
docker rmi "ghcr.io/terraform-linters/tflint-bundle" -f | true
displayName: 'Remove Terraform Quality Check Docker Images'
condition: always()