jason-johnson / azure-pipelines-tasks-terraform

Azure Pipelines extension for Terraform
MIT License
127 stars 55 forks source link

Ugly error when no tf files exist #252

Open davoodharun opened 2 years ago

davoodharun commented 2 years ago

Just got this error yesterday when runnning the TerraformCLI task (init):

##[error]Error: There was an error when attempting to execute the process '/opt/hostedtoolcache/terraform/1.1.5/x64/terraform'. This may indicate the process failed to start. Error: spawn /opt/hostedtoolcache/terraform/1.1.5/x64/terraform ENOENT

without any changes to my yaml pipelines. The Terraform Installer completes successfully:

Archive:  /home/vsts/work/_temp/terraform-1.1.5-a0b29100-d8ec-439c-9d20-a33fb97e663e.zip
  inflating: terraform               
Extracted terraform to dir:  /home/vsts/work/_temp/4e75bf9f-c154-40d3-a439-56368994a093
Caching tool: terraform 1.1.5 x64
Terraform installed in path:  /opt/hostedtoolcache/terraform/1.1.5/x64
Resolving path to Terraform tool...
Expected Terraform path:  /opt/hostedtoolcache/terraform/1.1.5/x64/terraform
Searching the following paths:  [ '/opt/hostedtoolcache/terraform/1.1.5/x64',
  '/opt/hostedtoolcache/terraform/1.1.5/x64/terraform' ]
Matched files:  [ '/opt/hostedtoolcache/terraform/1.1.5/x64/terraform' ]
Prepending PATH environment variable with directory: /opt/hostedtoolcache/terraform/1.1.5/x64
Verifying Terraform installation. Executing 'terraform version'
/opt/hostedtoolcache/terraform/1.1.5/x64/terraform version
Terraform v1.1.5
on linux_amd64

Pool: Azure Pipelines Image: ubuntu-latest Agent: Hosted Agent

Agent name: 'Hosted Agent' Agent machine name: 'fv-az98-615' Current agent version: '2.198.3' Operating System Virtual Environment Virtual Environment Provisioner Current image version: '20220207.1' Agent running as: 'vsts' Prepare build directory. Set build variables. Download all required tasks. Downloading task: TerraformInstaller (0.7.6) Downloading task: TerraformCLI (0.7.6) Checking job knob settings. Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} Finished checking job knob settings. Start tracking orphan processes.

There were some sitewide issues with Azure Pipelines this week. Im wondering if something changed on their end.

schxa commented 2 years ago

Same issue here. Did you figure out a solution?

keodime commented 2 years ago

I had a similar issue my problem was that I was trying to install and use TerraformCLI init in $(Build.ArtifactStagingDirectory). When I change the directory for the raw files instead it start working.

Cheers.

CorrenSoft commented 2 years ago

Every time that I got that error was because I was pointing the init/apply to a non-existing directory.

jason-johnson commented 2 years ago

@schxa @davoodharun Did the suggestions resolve or is there still an issue?

jason-johnson commented 1 year ago

I am able to reproduce: this happens when there is no terraform files present for the CLI task. We should fail more gracefully here.