foreach ($folder in $foldersToCheck) {
Write-Host "Running TFLint in $folder..."
$message = docker run --rm -v "$($gitRootFolder)/$($folder):/data" -v "$($env:PIPELINE_WORKSPACE)/s/Pipeline-Library/steps/tf-lint:/tflint" --entrypoint=/bin/sh ghcr.io/terraform-linters/tflint -c "tflint --init --fix --config /tflint/config.tflint.hcl";
$message
foreach ($line in $message) {
if ($line -contains "Error" -or $line -contains "Warning") {
Write-Host "##[error]TF LINT ISSUE FOUND IN $folder"
Write-Host $line -ForegroundColor DarkYellow
Write-Host "##vso[task.complete result=Failed;]"
}
}
}
Command
tflint
Terraform Configuration
# This configuration is supposed to trigger TFLINT because its missing source version. It also does not #contain the terraform version and providers.
##################################################################################
# RESOURCES
##################################################################################
module "zscaler" {
#source = "app.terraform.io/REPO/COMPANY/azurerm//zscaler"
#version = "2.2.13"
product_name = var.product_name
zpa_domain_names = var.zpa_domain_names
zpa_tcp_ports = var.zpa_tcp_ports
zpa_udp_ports = var.zpa_udp_ports
}
Summary
I have the following PowerShell script running in Azure DevOps. The Azure plugin gets installed but nothing else happens.
param ( [Parameter(Mandatory = $true)][string]$targetDirectory )
Set-Location $targetDirectory
$gitRootFolder = git rev-parse --show-toplevel $changes = git diff --name-only 'HEAD~' 'HEAD' $filesOfInterest = $changes | Where-Object {$ -ilike '*.tf' -or $ -ilike '*.tfvars'} $foldersToCheck = $filesOfInterest | ForEach-Object {Split-Path $_} | Sort-Object -Unique
foreach ($folder in $foldersToCheck) { Write-Host "Running TFLint in $folder..." $message = docker run --rm -v "$($gitRootFolder)/$($folder):/data" -v "$($env:PIPELINE_WORKSPACE)/s/Pipeline-Library/steps/tf-lint:/tflint" --entrypoint=/bin/sh ghcr.io/terraform-linters/tflint -c "tflint --init --fix --config /tflint/config.tflint.hcl"; $message
foreach ($line in $message) { if ($line -contains "Error" -or $line -contains "Warning") { Write-Host "##[error]TF LINT ISSUE FOUND IN $folder" Write-Host $line -ForegroundColor DarkYellow Write-Host "##vso[task.complete result=Failed;]" } } }
Command
tflint
Terraform Configuration
TFLint Configuration
Output
TFLint Version
0.50.3
Terraform Version
No response
Operating System