-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
50 lines (40 loc) · 1.1 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
pipeline {
agent any
environment {
PATH = "${PATH}:${getterraformpath()}"
}
stages{
stage("s3 create bucket"){
steps{
script{
invokeansi("s3-bucket.yml")
}
}
}
stage("Terraform init and apply - dev") {
steps{
sh label: "", returnStatus: true, script: 'terraform workspace new dev'
sh "terraform init"
script {
invokeansi("ansixterra.yml") + "--extra-vars app_env=dev"
}
}
}
stage("Terraform init and apply - prod") {
steps{
sh label: "", returnStatus: true, script: 'terraform workspace new prod'
sh "terraform init"
script{
invokeansi("ansixterra.yml") + "--extra-vars app_env=prod"
}
}
}
}
}
def getterraformpath(){
def tfHome = tool name: 'terraform', type: 'terraform'
return tfHome
}
def invokeansi(playbook){
ansiblePlaybook become: true, installation: 'ansible', playbook: "${playbook}"
}