Jenkinsfile运行Terraform

问题描述 投票:0回答:1

按照本教程https://medium.com/@devopslearning/100-days-of-devops-day-34-terraform-pipeline-using-jenkins-a3d81975730f

我想从Jenkins运行一个terraform文件我已经安装了Terraform插件版本1.0.9我在管道选项卡上创建一个新的管道项目我选择管道脚本并粘贴下面的脚本

node {
env.PATH += ":/opt/terraform_0.7.13/"


 stage ('Terraform Plan') {
 sh 'terraform plan -no-color -out=create.tfplan'
}

// Optional wait for approval
input 'Deploy stack?'

stage ('Terraform Apply') {
sh "terraform --version"
}

这是控制台输出

[Pipeline] {
[Pipeline] stage
[Pipeline] { (Terraform Plan)
[Pipeline] sh
[aws_terraform] Running shell script
+ terraform plan -no-color -out=create.tfplan
/var/lib/jenkins-slave/workspace/ow/ow_eng/aws_terraform@tmp/durable-53622951/script.sh: line 2: terraform: command not found
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
jenkins-pipeline terraform jenkins-groovy
1个回答
0
投票

terraform二进制文件未安装在正在执行管道的jenkins从服务器上。必须安装二进制文件才能使插件正常工作

© www.soinside.com 2019 - 2024. All rights reserved.