teamcity代理未发现Terraform可执行文件

我正在编写一个Teamcity管道,在其中使用terraform启动一些AWS实例。 我的管道使用docker一步一步调用所有步骤

但是,terraform初始化始终因terraform失败:未找到命令错误

[11:05:00][Step 2/6] Initialising terraform
[11:05:00][Step 2/6] terraform init
[11:05:00][Step 2/6] Makefile:41: recipe for target 'terraformApply' failed
[11:05:00][Step 2/6] make: terraform: Command not found

这是我的Makefile的terraformApply代码段

    @echo Download terraform
    # ${CURDIR}
    wget https://releases.hashicorp.com/terraform/0.12.20/terraform_0.12.20_linux_amd64.zip
    unzip -o terraform_0.12.20_linux_amd64.zip
    @echo Terraform downloaded
    # @echo Current Directory
    # ${CURDIR}
    sleep 60
    @echo *
    @echo Initialising terraform
    terraform init
    ## sudo terraform/terraform plan
    @echo Terraform initialised
    TF_VAR_AWS_ACCESS_KEY="****" TF_VAR_AWS_SECRET_KEY="****" terraform apply -auto-approve
    @echo Terraform setup done

我的管道在linux代理上运行。

I ran this Makefile directly on a linux machine, which works fine. However on teamcity pipeline it can't find the extracted terraform. Also, used echo * in Makefile to list all files present in the directory and I do see terraform present in the same path.

任何帮助将不胜感激。

评论
  • lsint
    lsint 回复

    Linux-based systems do not search for binaries in current working directory by default. After you have extracted terraform, you need to call it as ./terraform init.