尝试在 Azure Pipeline 中将
terraform init
作为任务运行时,出现错误并指出
生成 C:\hostedtoolcache\windows erraform .12.7\x64 erraform.exe ENOENT
安装看起来很好,因为在安装步骤中验证了基本功能(
terraform version
)
...
- task: TerraformInstaller@0
displayName: 'Install Terraform 0.12.7'
inputs:
terraformVersion: 0.12.7
- task: TerraformTaskV1@0
displayName: 'Terraform : init'
inputs:
command: 'init'
workingDirectory: '$(System.DefaultWorkingDirectory)/Terraform/terraform'
...
...
Verifying Terraform installation...
C:\hostedtoolcache\windows\terraform\0.12.7\x64\terraform.exe version
Terraform v0.12.7
Your version of Terraform is out of date! The latest version
is 0.12.19. You can update by downloading from www.terraform.io/downloads.html
Finishing: Install Terraform 0.12.7
...
C:\hostedtoolcache\windows\terraform\0.12.7\x64\terraform.exe validate
##[error]Error: There was an error when attempting to execute the process 'C:\hostedtoolcache\windows\terraform\0.12.7\x64\terraform.exe'. This may indicate the process failed to start. Error: spawn C:\hostedtoolcache\windows\terraform\0.12.7\x64\terraform.exe ENOENT
Finishing: Terraform : validate
许多其他用户报告通过添加结帐步骤成功修复了此问题,但管道自动执行此操作(大概以前的版本没有),并且手动添加它没有效果(由于选项不同,实际上花费了 2 秒的时间)。
原来工作目录路径不正确,因为目录结构已更改。
将所有指定工作目录从
Terraform/terraform
更改为 terraform
纠正了问题。
大概在这种情况下以及未执行
checkout
的情况下,Terraform 根本无法定位 main.tf
,但错误丢失或丢失。
我在重命名发布管道工件时偶然发现了这个错误,并且没有重新推送代码,因此导致缓存没有失效。
谢谢,我也遇到了类似的工作目录不正确的问题