-
Notifications
You must be signed in to change notification settings - Fork 90
/
Jenkinsfile
33 lines (31 loc) · 797 Bytes
/
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
pipeline{
agent any
environment {
PATH = "${PATH}:${getTerraformPath()}"
}
stages{
stage('S3 - create bucket'){
steps{
sh "ansible-playbook s3-bucket.yml"
}
}
stage('terraform init and apply - dev'){
steps{
sh returnStatus: true, script: 'terraform workspace new dev'
sh "terraform init"
sh "ansible-playbook terraform.yml"
}
}
stage('terraform init and apply - prod'){
steps{
sh returnStatus: true, script: 'terraform workspace new prod'
sh "terraform init"
sh "ansible-playbook terraform.yml -e app_env=prod"
}
}
}
}
def getTerraformPath(){
def tfHome = tool name: 'terraform-12', type: 'org.jenkinsci.plugins.terraform.TerraformInstallation'
return tfHome
}