错误:在 Azure Pipeline Terraform 期间生成 terraform ENOENT

问题描述 投票:0回答:3

尝试在 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'
...

安装 Terraform 0.12.7

...
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

Terraform:初始化

...
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 azure-pipelines terraform-provider-azure
3个回答
40
投票

原来工作目录路径不正确,因为目录结构已更改。

将所有指定工作目录从

Terraform/terraform
更改为
terraform
纠正了问题。

大概在这种情况下以及未执行

checkout
的情况下,Terraform 根本无法定位
main.tf
,但错误丢失或丢失。


1
投票

我在重命名发布管道工件时偶然发现了这个错误,并且没有重新推送代码,因此导致缓存没有失效。


0
投票

谢谢,我也遇到了类似的工作目录不正确的问题

© www.soinside.com 2019 - 2024. All rights reserved.