forked from srinivas1987devops/myweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkins-terraform
41 lines (38 loc) · 1.3 KB
/
Jenkins-terraform
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
pipeline {
parameters {
string(name: 'environment', defaultValue: 'prod', description: 'Workspace/Environment file to use for deployment')
string(name: 'region', defaultValue: 'ap-northeast-1', description: 'Workspace/region file to use for deployment')
}
agent any
stages {
stage('Download terraform code from Gihub') {
steps {
git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git'
}
}
stage('Terraform Ininitialization') {
steps {
sh """
cd /var/lib/jenkins/workspace/terraform
terraform init -reconfigure
"""
}
}
stage('Terraform Plan') {
steps {
sh """
cd /var/lib/jenkins/workspace/terraform
terraform plan -out=plan.${BUILD_NUMBER} -var profile=${params.environment} -var region=${params.region}
"""
}
}
stage('Terraform Apply') {
steps {
sh """
cd /var/lib/jenkins/workspace/terraform
terraform apply plan.${BUILD_NUMBER}
"""
}
}
}
}