无法在无所事事的虚拟机中从Jenkins管道运行Terraform

问题描述 投票:-2回答:1

我具有以下使用terraform插件执行terraform的管道设置。

这是我的环境。已使用用户游民已在terraform,jenkins中安装了centos7流民vm。 Terraform插件也已安装到Jenkins。 Terraform可以手动运行。管道使用te​​rraform时,它会失败。尝试了几种其他方式来设置Terraform路径,但都失败了。

Terraform位于/ usr / local / bin / terraform。


pipeline {

  agent any

  stages {
    stage('Set Terraform path') {
      steps {
        script {               
            def tfHome = tool name: 'terraform'
            env.PATH = "${tfHome}:${env.PATH}"
            // def tfhome = tool name: 'terraform', type: 'org.jenkinsci.plugins.terraform.TerraformInstallation'
            // env.PATH = "${tfhome}:${env.PATH}"
            // def tfHome = tool name: 'terraform', type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool'
            // env.PATH = "${tfHome}:${env.PATH}"
            echo "tfhome is ${tfhome}, env.PATH is ${env.PATH} "
        }
        // sh '/usr/local/bin/terraform -version'
        sh 'terraform -version'
      }
    }
  }
}

这里是错误消息:

Failed Node Use a tool from a predefined Tool Installation

hudson.AbortException: No org.jenkinsci.plugins.terraform.TerraformInstallation named terraform found
    at org.jenkinsci.plugins.workflow.steps.ToolStep$Execution.run(ToolStep.java:162)
    at org.jenkinsci.plugins.workflow.steps.ToolStep$Execution.run(ToolStep.java:133)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
jenkins vagrant terraform pipeline
1个回答
0
投票

我知道了。用户jenkins不能使用terraform工具。因此,我创建了一个指向terraform命令的符号链接。错误消失了!

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