generated from DTS-STN/next-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsettings.kts
291 lines (280 loc) · 10.8 KB
/
settings.kts
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
import jetbrains.buildServer.configs.kotlin.v2019_2.*
import jetbrains.buildServer.configs.kotlin.v2019_2.vcs.GitVcsRoot
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.dockerCommand
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.script
import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.vcs
import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule
import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.ScheduleTrigger
/*
The settings script is an entry point for defining a TeamCity
project hierarchy. The script should contain a single call to the
project() function with a Project instance or an init function as
an argument.
VcsRoots, BuildTypes, Templates, and subprojects can be
registered inside the project using the vcsRoot(), buildType(),
template(), and subProject() methods respectively.
To debug settings scripts in command-line, run the
mvnDebug org.jetbrains.teamcity:teamcity-configs-maven-plugin:generate
command and attach your debugger to the port 8000.
To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View
-> Tool Windows -> Maven Projects), find the generate task node
(Plugins -> teamcity-configs -> teamcity-configs:generate), the
'Debug' option is available in the context menu for the task.
*/
version = "2022.04"
project {
vcsRoot(Dev_SCH_HttpsGithubComDtsStnSecureClientHubMain)
vcsRoot(Dev_SCH_HttpsGithubComDtsStnSecureClientHubDynamic)
buildType(Build_Main)
buildType(Build_Performance)
buildType(Build_Dynamic)
buildType(CleanUpWeekly)
}
object Dev_SCH_HttpsGithubComDtsStnSecureClientHubMain : GitVcsRoot({
name = "https://github.com/DTS-STN/secure-client-hub/tree/_main"
url = "git@github.com:DTS-STN/secure-client-hub.git"
branch = "refs/heads/main"
branchSpec = "+:refs/heads/main"
authMethod = uploadedKey {
userName = "git"
uploadedKey = "dtsrobot"
}
})
object Dev_SCH_HttpsGithubComDtsStnSecureClientHubDynamic : GitVcsRoot({
name = "https://github.com/DTS-STN/secure-client-hub/tree/_dynamic"
url = "git@github.com:DTS-STN/secure-client-hub.git"
branch = "refs/heads/main"
branchSpec = "+:refs/heads/*"
authMethod = uploadedKey {
userName = "git"
uploadedKey = "dtsrobot"
}
})
/* Try and keep env.PROJECT value will be used throughout the helm scripts */
/* to build urls, name the application and many other things. folders and files in the */
/* helmfile directory should also match this value. */
object Build_Main: BuildType({
name = "Build_Main"
description = "Deploys main branch code on branch updates"
params {
param("teamcity.vcsTrigger.runBuildInNewEmptyBranch", "true")
param("env.PROJECT", "secure-client-hub")
param("env.BASE_DOMAIN","bdm-dev.dts-stn.com")
param("env.SUBSCRIPTION", "%vault:dts-sre/data/azure!/decd-dev-subscription-id%")
param("env.K8S_CLUSTER_NAME", "ESdCDPSBDMK8SDev-K8S")
param("env.RG_DEV", "ESdCDPSBDMK8SDev")
param("env.TARGET", "main")
param("env.BRANCH", "main")
param("env.ENV_EXAMPLE", "ServerOnlyExampleValue")
param("env.PUBLIC_ENV_EXAMPLE", "PublicClientExampleValue")
}
vcs {
root(Dev_SCH_HttpsGithubComDtsStnSecureClientHubMain)
}
steps {
dockerCommand {
name = "Build & Tag Docker Image"
commandType = build {
source = file {
path = "Dockerfile"
}
namesAndTags = "%env.ACR_DOMAIN%/%env.PROJECT%:%env.DOCKER_TAG%"
commandArgs = "--pull --build-arg ENV_EXAMPLE=%env.ENV_EXAMPLE% --build-arg NEXT_PUBLIC_ENV_EXAMPLE=%env.PUBLIC_ENV_EXAMPLE%"
}
}
script {
name = "Login to Azure and ACR"
scriptContent = """
az login --service-principal -u %TEAMCITY_USER% -p %TEAMCITY_PASS% --tenant %env.TENANT-ID%
az account set -s %env.SUBSCRIPTION%
az acr login -n MTSContainers
""".trimIndent()
}
dockerCommand {
name = "Push Image to ACR"
commandType = push {
namesAndTags = "%env.ACR_DOMAIN%/%env.PROJECT%:%env.DOCKER_TAG%"
}
}
script {
name = "Deploy w/ Helmfile"
scriptContent = """
cd ./helmfile
az account set -s %env.SUBSCRIPTION%
az aks get-credentials --admin --resource-group %env.RG_DEV% --name %env.K8S_CLUSTER_NAME%
helmfile -e %env.TARGET% apply
""".trimIndent()
}
}
triggers {
vcs {
branchFilter = "+:*"
}
}
})
object Build_Performance: BuildType({
name = "Build_Performance"
description = "Manually run performance environment"
params {
param("teamcity.vcsTrigger.runBuildInNewEmptyBranch", "true")
param("env.PROJECT", "secure-client-hub")
param("env.BASE_DOMAIN","bdm-dev.dts-stn.com")
param("env.SUBSCRIPTION", "%vault:dts-sre/data/azure!/decd-dev-subscription-id%")
param("env.K8S_CLUSTER_NAME", "ESdCDPSBDMK8SDev-K8S")
param("env.RG_DEV", "ESdCDPSBDMK8SDev")
param("env.TARGET", "main")
param("env.BRANCH", "perf")
param("env.ENV_EXAMPLE", "ServerOnlyExampleValue")
param("env.PUBLIC_ENV_EXAMPLE", "PublicClientExampleValue")
}
paused = true
vcs {
root(Dev_SCH_HttpsGithubComDtsStnSecureClientHubMain)
}
steps {
dockerCommand {
name = "Build & Tag Docker Image"
commandType = build {
source = file {
path = "Dockerfile"
}
namesAndTags = "%env.ACR_DOMAIN%/%env.PROJECT%:%env.DOCKER_TAG%"
commandArgs = "--pull --build-arg ENV_EXAMPLE=%env.ENV_EXAMPLE% --build-arg NEXT_PUBLIC_ENV_EXAMPLE=%env.PUBLIC_ENV_EXAMPLE%"
}
}
script {
name = "Login to Azure and ACR"
scriptContent = """
az login --service-principal -u %TEAMCITY_USER% -p %TEAMCITY_PASS% --tenant %env.TENANT-ID%
az account set -s %env.SUBSCRIPTION%
az acr login -n MTSContainers
""".trimIndent()
}
dockerCommand {
name = "Push Image to ACR"
commandType = push {
namesAndTags = "%env.ACR_DOMAIN%/%env.PROJECT%:%env.DOCKER_TAG%"
}
}
script {
name = "Deploy w/ Helmfile"
scriptContent = """
cd ./helmfile
az account set -s %env.SUBSCRIPTION%
az aks get-credentials --admin --resource-group %env.RG_DEV% --name %env.K8S_CLUSTER_NAME%
helmfile -e %env.TARGET% apply
""".trimIndent()
}
}
triggers {
vcs {
branchFilter = "+:*"
}
}
})
object Build_Dynamic: BuildType({
name = "Build_Dynamic"
description = "Builds and deploys every branch"
params {
param("teamcity.vcsTrigger.runBuildInNewEmptyBranch", "true")
param("env.PROJECT", "secure-client-hub")
param("env.BASE_DOMAIN","bdm-dev.dts-stn.com")
param("env.SUBSCRIPTION", "%vault:dts-sre/data/azure!/decd-dev-subscription-id%")
param("env.K8S_CLUSTER_NAME", "ESdCDPSBDMK8SDev-K8S")
param("env.RG_DEV", "ESdCDPSBDMK8SDev")
param("env.TARGET", "main")
param("env.BRANCH", "dyna-%teamcity.build.branch%")
param("env.ENV_EXAMPLE", "ServerOnlyExampleValue")
param("env.PUBLIC_ENV_EXAMPLE", "PublicClientExampleValue")
}
vcs {
root(Dev_SCH_HttpsGithubComDtsStnSecureClientHubDynamic)
}
steps {
dockerCommand {
name = "Build & Tag Docker Image"
commandType = build {
source = file {
path = "Dockerfile"
}
namesAndTags = "%env.ACR_DOMAIN%/%env.PROJECT%:%env.DOCKER_TAG%"
commandArgs = "--pull --build-arg ENV_EXAMPLE=%env.ENV_EXAMPLE% --build-arg NEXT_PUBLIC_ENV_EXAMPLE=%env.PUBLIC_ENV_EXAMPLE%"
}
}
script {
name = "Login to Azure and ACR"
scriptContent = """
az login --service-principal -u %TEAMCITY_USER% -p %TEAMCITY_PASS% --tenant %env.TENANT-ID%
az account set -s %env.SUBSCRIPTION%
az acr login -n MTSContainers
""".trimIndent()
}
dockerCommand {
name = "Push Image to ACR"
commandType = push {
namesAndTags = "%env.ACR_DOMAIN%/%env.PROJECT%:%env.DOCKER_TAG%"
}
}
script {
name = "Deploy w/ Helmfile"
scriptContent = """
cd ./helmfile
az account set -s %env.SUBSCRIPTION%
az aks get-credentials --admin --resource-group %env.RG_DEV% --name %env.K8S_CLUSTER_NAME%
helmfile -e %env.TARGET% apply
""".trimIndent()
}
}
triggers {
vcs {
branchFilter = """
+:*
-:dev
-:main
-:gh-pages
""".trimIndent()
}
}
})
object CleanUpWeekly: BuildType({
name = "CleanUpWeekly"
description = "Deletes deployments every Sunday"
params {
param("teamcity.vcsTrigger.runBuildInNewEmptyBranch", "true")
param("env.PROJECT", "secure-client-hub")
param("env.BASE_DOMAIN","bdm-dev.dts-stn.com")
param("env.SUBSCRIPTION", "%vault:dts-sre/data/azure!/decd-dev-subscription-id%")
param("env.K8S_CLUSTER_NAME", "ESdCDPSBDMK8SDev-K8S")
param("env.RG_DEV", "ESdCDPSBDMK8SDev")
param("env.TARGET", "dev")
param("env.BRANCH", "%teamcity.build.branch%")
}
vcs {
root(Dev_SCH_HttpsGithubComDtsStnSecureClientHubDynamic)
}
steps {
script {
name = "Login and Delete Deployment"
scriptContent = """
az login --service-principal -u %TEAMCITY_USER% -p %TEAMCITY_PASS% --tenant %env.TENANT-ID%
az account set -s %env.SUBSCRIPTION%
echo %env.PROJECT%-branch
kubectl get namespace | awk '/^%env.PROJECT%-dyna/{system("kubectl delete namespace " $1)}'
""".trimIndent()
}
}
triggers {
schedule {
schedulingPolicy = weekly {
dayOfWeek = ScheduleTrigger.DAY.Sunday
hour = 15
minute = 15
timezone = "America/New_York"
}
branchFilter = "+:main"
triggerBuild = always()
withPendingChangesOnly = false
triggerBuildOnAllCompatibleAgents = true
}
}
})