【发布时间】:2021-12-30 22:54:02
【问题描述】:
我正在通过 Jenkinsfile 运行 terraform 管道,在申请之前,我使用input(...) 块供用户批准。这是代码sn-p:
stage('tf_plan') {
agent {
label: 'Jenkins-Linux-Dev'
}
steps {
sh(
label: 'Terraform Plan',
script: '''
#!/usr/bin/env bash
terraform plan -input=false -no-color -out=plan.tfplan'
'''
)
}
}
stage('tf_approve') {
when { expression { return env.Action == 'apply' } }
options {
timeout( time: 1, unit: 'MINUTES' )
}
steps {
input(
message: 'Proceed with above Terraform Plan??',
ok: 'Proceed'
)
}
}
stage('tf_apply') {
agent {
label: 'Jenkins-Linux-Dev'
}
when { expression { return env.Action == 'apply' } }
steps {
sh(
label: 'Terraform Apply',
script: '''
#!/usr/bin/env bash
terraform apply -auto-approve -input=false -no-color plan.tfplan'
'''
)
}
}
stage('tf_plan') 工作得非常好,但是当env.Action = 'apply' 时,它在stage('tf_approve') 之后不再移动。它卡在Proceed or Abort 步骤 - 根本没有前进,点击它们中的任何一个。知道可能是什么问题吗?
非常感谢任何帮助。
-S
【问题讨论】:
标签: terraform jenkins-pipeline jenkins-groovy terragrunt