terraform - 错误: spawn terraform ENOENT during Azure Pipeline Terraform

标签 terraform azure-pipelines terraform-provider-azure

尝试在Azure Pipeline中将terraform init作为任务运行时,错误指出

spawn C:\hostedtoolcache\windows\terraform\0.12.7\x64\terraform.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

地形:初始化

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

许多其他用户报告说,通过添加一个 check out 步骤可以成功解决此问题,但是管道会自动执行此操作(可能是以前的版本没有执行此操作),并且手动添加它没有任何效果(由于选项不同,实际花费了2秒的时间)。

最佳答案

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

将所有命名的工作目录从Terraform/terraform更改为terraform即可解决此问题。

大概在这种情况下和未执行checkout的情况下,Terraform都无法定位main.tf,但是错误丢失或丢失。

关于terraform - 错误: spawn terraform ENOENT during Azure Pipeline Terraform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59794909/

相关文章:

azure-devops - 是否可以在 VSTS 上使用 AsciiDoc?

azure-devops - Azure Devops 管道 : import variables from template and declare variables in the same variables block

azure - Terraform Azure 数据工厂创建

amazon-web-services - 如何使用 Terraform 禁用 AWS Secrets Manager 的自动 secret 轮换?

Kubernetes ConfigMap YAML 到 Terraform Kubernetes

azure - Terraform 支持哪些 Azure API 版本?

terraform - 我可以在 TerraForm main.tf 文件中使用变量吗?

automation - 在 terraform 中使用工作空间时如何更改本地后端状态的路径?

azure - 在 Azure Pipeline 中签署代码时构建失败

automation - 运行 terraform init、terraform plan 或 apply 时出现无效字符错误