我目前被困在Azure DevOps管道中的初始点。所以我成功地安装了Terraform,但是在下一步它已经失败了。
pool:
name: Azure Pipelines
vmImage: ubuntu-latest
variables:
- name: terraform-working-directory
value: '$(System.DefaultWorkingDirectory)/terraform/'
stages :
- stage: terraform
jobs:
- deployment: deploy_terraform
continueOnError: false
environment: 'dev'
strategy:
runOnce:
deploy:
steps:
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-installer.TerraformInstaller@0
displayName: 'install'
inputs:
terraformVersion: '0.14.11'
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-cli.TerraformCLI@0
displayName: 'init'
inputs:
command: 'init'
workingDirectory: $(terraform-working-directory)
backendType: 'self-configured'Terraform文件:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.63.0"
}
}
backend "azurerm" {
resource_group_name = "xxx"
storage_account_name = "xxx"
container_name = "xxx"
key = "terraform.tfstate"
}
}它目前非常基础,而且还处于起步阶段。我收到的错误消息如下:
/opt/hostedtoolcache/terraform/0.14.11/x64/terraform init -backend-config=storage_account_name=xxx -backend-config=container_name=xxx -backend-config=key=xxx -backend-config=resource_group_name=xxx -backend-config=arm_subscription_id=xxx -backend-config=arm_tenant_id=*** -backend-config=arm_client_id=*** -backend-config=arm_client_secret=***
##[error]Error: There was an error when attempting to execute the process '/opt/hostedtoolcache/terraform/0.14.11/x64/terraform'. This may indicate the process failed to start. Error: spawn /opt/hostedtoolcache/terraform/1.0.0/x64/terraform ENOENT
Finishing: terraform init我已经在本地启动了terraform init和apply,它工作得很好
发布于 2021-06-18 21:58:24
请确保您有正确的工作目录。这条信息具有误导性。这个问题实际上是因为terraform找不到你的tf文件。
请添加此步骤以检查您的目录是否正确
- bash: ls $(terraform-working-directory)您使用部署作业,并且这里的存储库不是开箱即用的。请在作业开始时添加- checkout: self。
https://stackoverflow.com/questions/68032778
复制相似问题