-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsFile
76 lines (69 loc) · 2.12 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
pipeline{
agent any
tools {
"org.jenkinsci.plugins.terraform.TerraformInstallation" "Terraform 20706"
}
environment {
TF_HOME = tool('Terraform 20706')
TF_IN_AUTOMATION = "true"
PATH = "$TF_HOME:$PATH"
}
stages {
stage('Terraform Init'){
steps {
ansiColor('xterm') {
dir('terraform-libvirt'){
git branch: 'main', url: 'https://github.com/insani4c/terraform-libvirt'
echo 'Initializing Terraform'
sh '''
cd deployment
terraform init --upgrade --reconfigure
'''
}
}
}
}
stage('Terraform Validate'){
steps {
ansiColor('xterm') {
dir('terraform-libvirt/deployment'){
sh '''
terraform validate
'''
}
}
}
}
stage('Terraform Plan'){
steps {
ansiColor('xterm') {
dir('terraform-libvirt/deployment'){
echo 'Creating Terraform Plan'
sh '''
terraform plan -out /tmp/jenkins_tf_${GIT_COMMIT}_${BUILD_ID}.plan
'''
}
}
}
}
stage('Waiting for Approval'){
steps {
timeout(time: 24, unit: 'HOURS') {
input (message: "Deploy the infrastructure?")
}
}
}
stage('Terraform Apply'){
steps {
ansiColor('xterm') {
dir('terraform-libvirt/deployment'){
echo 'Applying the plan'
sh '''
terraform apply -parallelism 25 /tmp/jenkins_tf_${GIT_COMMIT}_${BUILD_ID}.plan
'''
}
}
}
}
}
}