-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
52 lines (44 loc) · 1.16 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
pipeline {
agent any
tools {
terraform 'Terraform' // Use the name you configured in the Global Tool Configuration
}
environment {
AWS_ACCESS_KEY_ID = credentials('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = credentials('AWS_SECRET_ACCESS_KEY')
}
stages {
stage('Checkout Code') {
steps {
// che
checkout scm
}
}
stage('Terraform Init') {
steps {
// Initialize the Terraform working directory
sh 'pwd ; terraform init'
}
}
stage('Terraform Plan') {
steps {
// Generate and display an execution plan
sh 'terraform plan'
}
}
stage('Terraform Apply') {
steps {
// Apply the Terraform plan automatically
sh ' terraform destroy --auto-approve'
}
}
}
post {
success {
echo 'Terraform commands executed successfully.'
}
failure {
echo 'Terraform execution failed.'
}
}
}