/
jenkins.yaml
468 lines (458 loc) · 18.3 KB
/
jenkins.yaml
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
---
persistence:
enabled: true
controller:
healthProbeReadinessFailureThreshold: 90
healthProbeLivenessFailureThreshold: 90
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- jenkins
topologyKey: "kubernetes.io/hostname"
jenkinsAdminEmail: jenkins@g4v.dev
serviceType: ClusterIP
serviceAnnotations:
prometheus.io/path: /prometheus
prometheus.io/port: "8080"
prometheus.io/scrape: "true"
image: halkeye/jenkins
tag: "latest@sha256:3c2d38f92378400d03c93385f9824b356a441ef8f25fe08d3ce1b66b1efcfe3c"
sidecars:
configAutoReload:
enabled: true
resources:
requests:
cpu: "2000m"
memory: "1000Mi"
limits:
cpu: "4000m"
memory: "4096Mi"
ingress:
enabled: true
hostName: ci.g4v.dev
ingressClassName: nginx
path: /
tls:
- secretName: ci-tls
hosts:
- ci.g4v.dev
annotations:
cert-manager.io/cluster-issuer: letsencrypt
kubernetes.io/tls-acme: "true"
nginx.ingress.kubernetes.io/proxy-body-size: 2000m
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
numExecutors: 0
overwriteConfig: false
overwritePlugins: true
installPlugins: false
runAsUser: 1000
fsGroup: 1000
JCasC:
defaultConfig: false
configScripts:
zzzcustom: |-
security:
queueItemAuthenticator:
authenticators:
- global:
strategy: "triggeringUsersAuthorizationStrategy"
jenkins:
disableRememberMe: false
agentProtocols:
- "JNLP4-connect"
- "Ping"
authorizationStrategy:
projectMatrix:
permissions:
- "GROUP:Overall/Read:authenticated"
- "USER:Agent/Build:anonymous"
- "USER:Job/Discover:anonymous"
- "USER:Overall/Read:anonymous"
- "USER:Overall/Administer:halkeye"
markupFormatter: "markdownFormatter"
securityRealm:
oic:
authorizationServerUrl: "https://auth.g4v.dev/application/o/authorize/"
clientId: "${OIC_AUTH_CLIENT_ID}"
clientSecret: "${OIC_AUTH_CLIENT_SECRET}"
disableSslVerification: false
endSessionEndpoint: "https://auth.g4v.dev/if/session-end/jenkins/"
escapeHatchEnabled: false
logoutFromOpenidProvider: true
scopes: "email groups openid profile"
tokenServerUrl: "https://auth.g4v.dev/application/o/token/"
userInfoServerUrl: "https://auth.g4v.dev/application/o/userinfo/"
wellKnownOpenIDConfigurationUrl: "https://auth.g4v.dev/application/o/jenkins/.well-known/openid-configuration"
userNameField: "preferred_username"
emailFieldName: "email"
fullNameFieldName: "name"
groupsFieldName: "groups"
numExecutors: 0
nodes:
- permanent:
name: "thor"
labelString: "home"
numExecutors: 4
remoteFS: "/home/jenkins-agent"
launcher:
jnlp:
webSocket: true
workDirSettings:
disabled: false
failIfWorkDirIsMissing: false
internalDir: "remoting"
retentionStrategy: "always"
clouds:
- digitalOcean:
authTokenCredentialId: halkeye-digitalocean
privateKeyCredentialId: halkeye-digitalocean-sshkey
connectionRetryWait: 10
instanceCap: 5
name: "dojenkins"
sshKeyId: 29638582
templates:
- idleTerminationInMinutes: 10
installMonitoring: false
instanceCap: 5
labellessJobsAllowed: true
# doctl compute image list --public | grep -i docker | grep 20.04
# 87786318 Docker 19.03.12 on Ubuntu 20.04
imageId: "87786318"
name: "agent"
numExecutors: 2
regionId: "tor1"
setupPrivateNetworking: false
sizeId: "s-2vcpu-2gb"
sshPort: 22
username: "root"
workspacePath: "/jenkins/"
timeoutMinutes: 5
usePrivateNetworking: false
crumbIssuer:
standard:
excludeClientIPFromCrumb: true
unclassified:
bitbucketEndpointConfiguration:
endpoints:
- bitbucketCloudEndpoint:
credentialsId: "bitbucket-halkeye"
enableCache: false
manageHooks: true
repositoriesCacheDuration: 0
teamCacheDuration: 0
location:
adminAddress: "jenkins@g4v.dev"
url: "https://ci.g4v.dev/"
email-ext:
defaultReplyTo: "jenkins@g4v.dev"
mailAccount:
smtpPort: "25"
smtpHost: "${SMTP_SERVER}"
gitHubPluginConfig:
configs:
- credentialsId: "github-admin-halkeye"
hookUrl: "https://ci.g4v.dev/github-webhook/"
mailer:
replyToAddress: "jenkins@g4v.dev"
smtpHost: "${SMTP_SERVER}"
smtpPort: "25"
buildDiscarders:
configuredBuildDiscarders:
- "jobBuildDiscarder"
- simpleBuildDiscarder:
discarder:
logRotator:
numToKeepStr: "5"
themeManager:
disableUserThemes: false
theme: "darkSystem"
globalDefaultFlowDurabilityLevel:
durabilityHint: PERFORMANCE_OPTIMIZED
globalLibraries:
libraries:
- name: "github.com/halkeye/jenkins-shared-library"
implicit: true
defaultVersion: "master"
retriever:
modernSCM:
scm:
git:
credentialsId: "github-app"
id: "29f65a8c-bc76-4fba-bddc-ac27fa04ccf4"
remote: "https://github.com/halkeye/jenkins-shared-library"
credentials:
system:
domainCredentials:
- credentials:
- gitHubApp:
appID: "74743"
description: "GitHub app - github-app"
id: "github-app"
privateKey: "${GITHUB_APP_KEY}"
owner: "halkeye"
- gitHubApp:
appID: "74743"
description: "GitHub app"
description: "GitHub app - github-app-halkeye"
id: "github-app-halkeye"
privateKey: "${GITHUB_APP_KEY}"
owner: "halkeye"
- gitHubApp:
appID: "74743"
description: "GitHub app - github-app-halkeye-docker"
id: "github-app-halkeye-docker"
privateKey: "${GITHUB_APP_KEY}"
owner: "halkeye-docker"
- gitHubApp:
appID: "74743"
description: "GitHub app - github-app-halkeye-helm-charts"
id: "github-app-halkeye-helm-charts"
privateKey: "${GITHUB_APP_KEY}"
owner: "halkeye-helm-charts"
- usernamePassword:
id: bitbucket-halkeye
username: halkeye
password: "${BITBUCKET_HALKEYE_PASSWORD}"
- usernamePassword:
id: contentful-halkeye
username: "${CONTENTFUL_HALKEYE_USERNAME}"
password: "${CONTENTFUL_HALKEYE_PASSWORD}"
- usernamePassword:
id: dockerhub-halkeye
username: "${DOCKERHUB_HALKEYE_USERNAME}"
password: "${DOCKERHUB_HALKEYE_PASSWORD}"
- string:
id: modio-halkeye
secret: "${MODIO_HALKEYE_ACCESS_TOKEN}"
- string:
id: halkeye-digitalocean
secret: "${DIGITAL_OCEAN_TOKEN}"
- basicSSHUserPrivateKey:
id: halkeye-digitalocean-sshkey
privateKeySource:
directEntry:
privateKey: "${DIGITAL_OCEAN_SSH_KEY}"
- file:
fileName: "kubeconfig"
id: "halkeye-digitalocean-kubeconfig"
description: "Kubeconfig file for dok8s"
scope: GLOBAL
secretBytes: "${base64:${DIGITAL_OCEAN_KUBECONFIG}}"
- string:
id: github-admin-halkeye
secret: "${GITHUB_ADMIN_HALKEYE_SECRET}"
- usernamePassword:
id: github-halkeye
username: "${GITHUB_HALKEYE_USERNAME}"
password: "${GITHUB_HALKEYE_PASSWORD}"
- string:
id: github-halkeye-react-book-reader
secret: "${GITHUB_HALKEYE_REACT_BOOK_READER_SECRET}"
- usernamePassword:
id: goodreads
username: "${GOODREADS_USERNAME}"
password: "${GOODREADS_PASSWORD}"
- basicSSHUserPrivateKey:
id: halkeye-bitbucket
passphrase: "${HALKEYE_BITUCKET_PASSPHRASE}"
privateKeySource:
directEntry:
privateKey: "${HALKEYE_BITUCKET_KEY}"
username: "${HALKEYE_BITUCKET_USERNAME}"
- usernamePassword:
id: halkeye-quay
username: "${HALKEYE_QUAY_USERNAME}"
password: "${HALKEYE_QUAY_PASSWORD}"
- usernamePassword:
id: halkeye-surge
username: "${HALKEYE_SURGE_USERNAME}"
password: "${HALKEYE_SURGE_PASSWORD}"
- string:
id: netlify-gavinmogan
secret: "${GITHUB_NETLIFY_GAVINMOGAN_SECRET}"
- usernamePassword:
id: sauce-minecraft-gavinmogan
username: "${SAUCE_MINECRAFT_GAVINMOGAN_USERNAME}"
password: "${SAUCE_MINECRAFT_GAVINMOGAN_PASSWORD}"
- basicSSHUserPrivateKey:
id: thor-ssh-key
username: "jenkins"
privateKeySource:
directEntry:
privateKey: "${THOR_SSH_KEY}"
- file:
# gpg -a --export-secret-keys jenkins@g4v.dev
id: jenkins-gpg-secret
fileName: key.asc
scope: GLOBAL
description: "GPG data for jenkins@g4v.dev"
secretBytes: "${readFileBase64:/run/secrets/additional/JENKINS_GPG_SECRET}"
- file:
# gpg --export-ownertrust
id: jenkins-gpg-ownertrust
fileName: ownertrust.asc
scope: GLOBAL
description: "GPG ownertrust data for jenkins@g4v.dev"
secretBytes: "${readFileBase64:/run/secrets/additional/JENKINS_GPG_OWNERTRUST}"
- string:
id: jenkins-gpg-passphrase
secret: "${JENKINS_GPG_PASSPHRASE}"
- string:
id: discord-webhook
secret: "${DISCORD_WEBHOOK}"
- string:
id: halkeye-crates
secret: "${CARGO_REGISTRY_TOKEN}"
jobs:
- script: |-
def githubOrgs = [
"halkeye": [
"public": true,
"repos": [
"android-sms",
"bamboohr-employee-stats",
"codacy-maven-plugin",
"discord-twitch-streamers",
"dok8s",
"EcoNextFoodPlugin",
"eslint-formatter-multiple",
"flask_atlassian_connect",
"GamesDealsBot",
"gatsby-jenkins-io",
"gatsby-source-goodreads",
"gatsby-theme-nodeschool",
"get_groups",
"gitter-irc-bridge",
"git-version-commits",
"go_windows_stats",
"graphite_scripts",
"halkeye-ansible",
"helm-repo-html",
"http_bouncer_client",
"http_bouncer_server",
"hubot-plugins",
"infinicatr",
"kubernetes-usb-labeler",
"language-versions",
"mastodon-twitter-poster",
"minecraft.gavinmogan.com",
"proxy-s3-google-oauth",
"react-book-reader",
"release-dashboard",
"self-service-password",
"slack-foodee",
"slacktalker",
"soundboard",
"typos-json-to-checkstyle",
"typos-json-to-github-annotations",
"www-gavinmogan-com",
]
],
"nodeschool": [
"public": true,
"repos": [
"vancouver"
]
],
"halkeye-helm-charts": ["public": true],
"halkeye-docker": ["public": true],
"nodeschoolyvr": ["public": true],
]
def appEnabledAccounts = ["halkeye", "halkeye-helm-charts", "halkeye-docker"]
githubOrgs.keySet().each { githubOrg ->
organizationFolder(githubOrg) {
authorization {
if (githubOrgs[githubOrg]["public"]) {
["anonymous", "authorized", "authenticated"].each { user ->
permission("hudson.model.Item.Read", user)
permission("hudson.model.Item.Discover", user)
}
}
if (githubOrgs[githubOrg]["allowed_read_users"]) {
githubOrgs[githubOrg]["allowed_read_users"].each { user ->
permission("hudson.model.Item.Read", user)
permission("hudson.model.Item.Discover", user)
}
}
}
buildStrategies {
buildAnyBranches {
strategies {
buildAllBranches {
strategies {
buildRegularBranches()
// skipInitialBuildOnFirstBranchIndexing()
}
}
}
}
buildAnyBranches {
strategies {
buildAllBranches {
strategies {
buildTags {
atLeastDays '-1'
atMostDays '3'
}
// skipInitialBuildOnFirstBranchIndexing()
}
}
}
}
}
orphanedItemStrategy {
defaultOrphanedItemStrategy {
pruneDeadBranches(true)
numToKeepStr("5")
daysToKeepStr("")
}
discardOldItems {
numToKeep(5)
}
}
organizations {
github {
credentialsId(appEnabledAccounts.contains(githubOrg) ? "github-app-" + githubOrg : "github-halkeye")
repoOwner(githubOrg)
traits {
if (githubOrgs[githubOrg].repos) {
sourceRegexFilter { "^" + regex(githubOrgs[githubOrg].repos.join("|") + "\$") }
}
pruneStaleBranchTrait()
gitHubExcludeArchivedRepositories()
gitHubBranchDiscovery {
strategyId(1) // 1-Exclude branches that are also filed as PRs
}
gitHubPullRequestDiscovery {
strategyId(1) // Merging the pull request with the current target branch revision
}
gitHubTagDiscovery()
gitHubExcludeArchivedRepositories()
pullRequestLabelsBlackListFilterTrait {
labels('on-hold ci-skip skip-ci')
}
notificationContextTrait {
contextLabel("continuous-integration/ci.g4v.dev")
typeSuffix(true)
}
}
}
}
configure {
def traits = it / navigators / 'org.jenkinsci.plugins.github__branch__source.GitHubSCMNavigator' / traits
// Not discovered by Job-DSL: need to be configured as raw-XML
traits << 'org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait' {
strategyId(1) // 1-Merging the pull request with the current target branch revision
trust(class: 'org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission')
}
}
}
}
rbac:
create: true
readSecrets: true