簡體   English   中英

無法從 vagrant 虛擬機中的 Jenkins 管道運行 terraform

[英]Unable to run terraform from Jenkins pipeline in vagrant virtual machine

我有以下管道設置,它使用 terraform 插件來執行 terraform。

這是我的環境。 一個centos7 vagrant vm已安裝terraform, jenkins 使用用戶Z63623900C8BBF21C7036C50C5B7A204。 Terraform 插件也安裝到 Jenkins。 Terraform 可以手動運行。 當 terraform 被管道使用時,它失敗了。 嘗試了其他幾種方法來設置 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 不能使用 terraform 工具。 所以我創建了一個指向 terraform 命令的符號鏈接。 錯誤消失了!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM