-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ops_Jenkinsfile
124 lines (118 loc) · 3.88 KB
/
Ops_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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
String pipelineVersion = "feature/FI-744-install-terraform-tool"
library("jenkins-pipeline@${pipelineVersion}")
// PIPELINE VARS
targetInfraEnv = "unknown"
targetConfigs = "unknown"
namePrefix = "unknown"
loglevel = "INFO"
// BRANCH PATTERNS
featureBranchPattern = "feature/"
developmentBranchPattern = "develop"
testBranchPattern = "test"
hotfixBranchPattern = "hotfix/"
releaseBranchPattern = "release/"
masterBranchPattern = "master"
// DETERMINE PIPELINE VARS BASED ON BRANCH PATTERN
if (env.BRANCH_NAME =~ ".*${featureBranchPattern}.*") {
targetConfigs = "feature"
targetInfraEnv = "dalDC01_feature"
namePrefix = env.BRANCH_NAME.replaceAll("/", "-")
} else if (env.BRANCH_NAME =~ ".*${developmentBranchPattern}.*") {
targetConfigs = "dev"
targetInfraEnv = "dalDC01_dev"
namePrefix = "dev"
} else if (env.BRANCH_NAME =~ ".*${testBranchPattern}.*") {
targetConfigs = "test"
targetInfraEnv = "dalDC01_test"
namePrefix = "test"
} else if (env.BRANCH_NAME =~ ".*${releaseBranchPattern}.*") {
targetConfigs = "staging"
targetInfraEnv = "dalDC01_staging"
namePrefix = "staging"
} else if (env.BRANCH_NAME =~ ".*${masterBranchPattern}.*" || env.BRANCH_NAME =~ ".*${hotfixBranchPattern}.*") {
targetConfigs = "prod"
targetInfraEnv = "dalDC01_prod"
namePrefix = "prod"
}
components = [
ops_cluster: [
name: "ops_cluster",
description: "Web Cluster",
version: "latest",
type: "infrastructure",
config: [
infrastructureType: "vsphere",
terraformOptions: [
version: "1.0.5"
],
terraformDirectories: [
mainDirectory: "VirtualMachines"
],
terraformVars: [
name_prefix: "ops-cluster-${namePrefix}",
consul_src_def: "/root/.ssh",
consul_tls_src_files: "/root/.ssh"
],
terraformVarsFiles: [
mainVarsFile: "./clusters/ops/${targetConfigs}/main.tfvars",
cloudVarsFile: "./clusters/ops/${targetConfigs}/cloud.tfvars",
provisioningVarsFile: "./clusters/ops/${targetConfigs}/provisioning.tfvars",
],
terraformBackendFiles: [
mainBackendFile: "./clusters/ops/backend.tf",
]
],
scm: [
current: [
repoName: "terraform-vsphere",
branchName: "${env.BRANCH_NAME}"
],
ansible: [
repoName: "ansible-deployments",
branchName: "develop"
]
]
]
]
stages = [
deploy_ops_cluster: [
title: "Deploy Ops Cluster",
description: "Deploy Ops worker Cluster to vSphere",
type: "install",
agent: "agent-deploytools",
config: [
installType: "infrastructure_install",
infrastructure: "ops_cluster",
targetEnv: targetInfraEnv,
targets: [
vsphereVMs: [
name: "ops_cluster",
strategy: "terraform",
graphFlag: false,
terraformVersion: "version",
terraformDirectory: "mainDirectory",
terraformVars: [
"name_prefix"
],
terraformVarsFiles: [
"mainVarsFile",
"cloudVarsFile",
"provisioningVarsFile"
],
terraformBackendFile: "mainBackendFile"
]
]
],
withScm: [
primaryScm: [
scmEnv: "frankBitBucketRepoHost",
scmName: "current"
],
extraScm1: [
scmEnv: "frankBitBucketRepoHost",
scmName: "ansible"
]
]
]
]
runPipeline(components, stages, loglevel)