Matthieu Ducorps
Matthieu Ducorps

Reputation: 160

Jenkins and terraform plugin, terraform file not found

I’m running Jenkins v2.263.2 with Terraform plugin on Debian 10. I have created a freestyle project to trigger my terraform deployment, which is first pulling from my git repo and the trigger terraform, but at the terraform step I’m getting this error:

FATAL: java.io.FileNotFoundException: Configuration path not found [/var/lib/jenkins/workspace/Terraform/terraform/test.tf].
    at org.jenkinsci.plugins.terraform.TerraformBuildWrapper.setupWorkspace(TerraformBuildWrapper.java:367)
    at org.jenkinsci.plugins.terraform.TerraformBuildWrapper.executeGet(TerraformBuildWrapper.java:208)
    at org.jenkinsci.plugins.terraform.TerraformBuildWrapper.setUp(TerraformBuildWrapper.java:256)
    at hudson.model.Build$BuildExecution.doRun(Build.java:157)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:514)
    at hudson.model.Run.execute(Run.java:1907)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)

Finished: FAILURE

Also if I look at the OS level I do have access to this file with jenkins user, so I’m not clear what is wrong with my setup.

jenkins@jenkins:~/workspace/Terraform/terraform$ cat test.tf
data "xenorchestra_template" "template" {
    name_label = "Galaxy_Template"
}

data "xenorchestra_network" "net" {
  name_label = "ETH"
}

resource "xenorchestra_vm" "bar" {
    memory_max = 1073733632
    cpus  = 1
    name_label = "MyName"
    name_description = "Mydescription"
    template = data.xenorchestra_template.template.id
    network {
          network_id = data.xenorchestra_network.net.id
    }

    disk {
      sr_id = "c7e5cf80-2b3e-c0ed-6f1e-09f1417b7d24"
      name_label = "WDisk"
      size = 62212254720
    }
}

Upvotes: 1

Views: 826

Answers (1)

Transformer
Transformer

Reputation: 7429

  • First, check your setup, if your node path to Terraform binaries is correct

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

  stage ('Terraform Plan') {
    sh 'terraform plan -no-color -out=create.tfplan'
}
  • Second, check if the terraform binary is installed on the jenkins slave that is executing the pipeline, the binary must be installed to have the plugin work

Upvotes: 1

Related Questions