I am trying to run my terraform script through jenkins but I am getting terraform not found error. I checked terraform version in jenkins it is 1.5.7. I am not sure why it is throwing error.
Below is my jenkins pipeline
#!groovy
pipeline {
agent any
environment {
BUILD_TARGET = "s3_tf"
DOCKER_REGISTRY = 's3group.azurecr.io'
GITREPO_URL = 'https://gitlab.s3groupinc.com/devops/terraform.git'
}
options {
skipStagesAfterUnstable()
disableConcurrentBuilds()
}
stages {
stage('Preparation ') {
agent {
any {
reuseNode true
}
}
steps {
sh ‘echo “Preparation and checkout”’
deleteDir() // Clean workspace
checkout ([$class: ‘GitSCM’,
branches: [[name: ‘*/s3_tf’]],
extensions: [],
userRemoteConfigs: [[credentialsId: ‘gitlab-credential’,
url: “${GITREPO_URL}”]]])
}
}
stage(‘init_and_plan’) {
steps {
sh “terraform init”
sh “terraform plan”
}
}
}
}