【发布时间】:2021-09-26 09:46:35
【问题描述】:
该项目的目标是:使用 terraform 启动 6 个 AWS 实例并将 kafka 安装到其中,同时在本地手动运行 terraform 和 ansible 代码,但通过 jenkins 尝试抛出错误。
运行 Jenkins 管道,源代码在 gitlab 中,我在 Build 步骤中使用了“Execute Shell”,代码如下:
#!/bin/bash
cd terraform-aws-ec2-with-vpc
chmod 400 oregonkeypair.pem
terraform init
terraform apply -auto-approve
但它的抛出错误
Started by user company
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/Kafka-infra
The recommended git tool is: NONE
using credential a4eec3ff-c405-4ba6-aff2-239275a889c4
Cloning the remote Git repository
Cloning repository https://gitlab.com/company/company-cp-ansible-terraform-aws
> git init /var/jenkins_home/workspace/Kafka-infra # timeout=10
Fetching upstream changes from https://gitlab.com/company/company-cp-ansible-terraform-aws
> git --version # timeout=10
> git --version # 'git version 2.20.1'
using GIT_ASKPASS to set credentials
> git fetch --tags --force --progress -- https://gitlab.com/company/company-cp-ansible-terraform-aws +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url https://gitlab.com/company/company-cp-ansible-terraform-aws # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision e1769571a021785178b84287566e625d46cf4f54 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f e1769571a021785178b84287566e625d46cf4f54 # timeout=10
Commit message: "Merge branch 'ndey1-master-patch-44242' into 'master'"
First time build. Skipping changelog.
[Kafka-infra] $ /bin/bash /tmp/jenkins1038642698264658523.sh
/tmp/jenkins1038642698264658523.sh: line 5: terraform: command not found
/tmp/jenkins1038642698264658523.sh: line 6: terraform: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
【问题讨论】:
-
你需要在构建代理中安装terraform。
标签: amazon-web-services jenkins terraform