Jenkins job cannot find terraform installation and fails with error

Viewed 508

I am setting up a Jenkins pipeline which will deploy a spring boot application to EKS. I have the same application installed using cloudformation and works fine. I am now trying to migrate it over to use terraform. I have terraform installed on the ec2 Ubuntu box in the /usr/bin directory and have the terraform plugin installed and configured as shown in the picture. enter image description here

pipeline {
    agent any
    tools {
        terraform 'terraform-11'
    }
    
    triggers {
        pollSCM '* * * * *'
    }
    stages {
        stage('Terraform init') {
            steps {
                sh 'terraform init'
            }
        }
        stage('Terraform apply') {
            steps {
                sh 'terraform apply --auto-approve'
            }
        }
    }
}

This is my pipeline code which errors out with the following error:

  • terraform init /var/jenkins_home/jobs/hello-job-aws-terrform/workspace@tmp/durable-48ffb117/script.sh: 1: /var/jenkins_home/jobs/hello-job-aws-terrform/workspace@tmp/durable-48ffb117/script.sh: terraform: not found
0 Answers
Related