-
Notifications
You must be signed in to change notification settings - Fork 158
/
Copy pathJenkinsfile
53 lines (52 loc) · 1.96 KB
/
Jenkinsfile
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
42
43
44
45
46
47
48
49
50
51
52
53
pipeline {
agent { node { label 'terraform-node' } }
parameters {
choice(name: 'Deployment_Type', choices:['apply','destroy'],description:'The deployment type')
}
environment {
EMAIL_TO = '[email protected]'
}
stages {
stage('1.Terraform init') {
steps {
echo 'terraform init phase'
sh 'terraform init'
}
}
stage('2.Terraform plan') {
steps {
echo 'terraform plan phase'
sh 'AWS_REGION=us-west-2 terraform plan'
}
}
stage('3.Manual Approval') {
input {
message "Should we proceed?"
ok "Yes, we should."
parameters{
choice (name: 'Manual_Approval', choices: ['Approve','Reject'], description: 'Approve or Reject the deployment')
}
}
steps {
echo "Deployment ${Manual_Approval}"
}
}
stage('4.Terraform Deploy') {
steps {
echo 'Terraform ${params.Deployment_Type} phase'
sh "AWS_REGION=us-west-2 terraform ${params.Deployment_Type} --auto-approve"
sh("""scripts/update-kubeconfig.sh""")
sh("""scripts/install_helm.sh""")
}
}
stage ('5. Email Notification') {
steps {
mail bcc: '[email protected]', body: '''Terraform deployment is completed.
Let me know if the changes look okay.
Thanks,
Dominion System Technologies,
+1 (313) 413-1477''', cc: '[email protected]', from: '', replyTo: '', subject: 'Terraform Infra deployment completed!!!', to: '[email protected]'
}
}
}
}