-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinfra.groovy
More file actions
61 lines (50 loc) · 2.01 KB
/
Copy pathinfra.groovy
File metadata and controls
61 lines (50 loc) · 2.01 KB
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
import hudson.model.*
node {
deleteDir()
def groovy_scripts_path = 'jenkins-pipeline-groovy'
stage('bootstrap') {
dir(groovy_scripts_path) {
sh """
git clone git@github.com:OGProgrammer/jenkins-pipeline-groovy.git --branch=master .
"""
}
dir(groovy_scripts_path) {
functions = load("functions.groovy")
}
}
stage('prep') {
def env_name = "${env_name}"
def region = "${region}"
def action = "${action}"
println "Preforming [${action}] with AWS infrastrucutre [${env_name}] in the [${region}] region."
// Build the terraform vars
tfvars_file_data = ''
def newLine = System.getProperty('line.separator')
// Jenkins parameters set manually
tfvars_file_data += "env_name = \"${env_name}\"${newLine}"
tfvars_file_data += "region = \"${region}\"${newLine}"
// Get all the terraform variables for our infrastructure from a manifest
def infrastructureManifest = functions.getInfrastructureManifest(env_name, region)
for (data in infrastructureManifest) {
tfvars_file_data += "${data.key} = \"${data.value}\"${newLine}"
}
infrastructureManifest = null
// Get docker manifest vars
def dockerManifest = functions.getDockerManifest()
for (data in dockerManifest) {
tfvars_file_data += "${data.key} = \"${data.value}\"${newLine}"
}
dockerManifest = null
// Get s3prefix manifest var
def terraformManifest = functions.getTerraformManifest()
for (data in terraformManifest ) {
tfvars_file_data += "${data.key} = \"${data.value}\"${newLine}"
}
terraformManifest = null
}
stage ('plan') {
git url: "git@github.com:OGProgrammer/terraform-aws-ecs-infrastructure.git", branch: "master"
writeFile file: 'variables.tfvars', text: tfvars_file_data
sh "./tf-${action}.sh variables.tfvars"
}
}