-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
80 lines (68 loc) · 3.31 KB
/
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
library(
identifier: 'pipeline-lib@4.8.0',
retriever: modernSCM([$class: 'GitSCMSource',
remote: 'https://github.com/SmartColumbusOS/pipeline-lib',
credentialsId: 'jenkins-github-user'])
)
properties([
pipelineTriggers([scos.dailyBuildTrigger()]),
parameters([
booleanParam(defaultValue: false, description: 'Deploy to development environment?', name: 'DEV_DEPLOYMENT'),
string(defaultValue: 'development', description: 'Image tag to deploy to dev environment', name: 'DEV_IMAGE_TAG')
])
])
def image
def doStageIf = scos.&doStageIf
def doStageIfDeployingToDev = doStageIf.curry(env.DEV_DEPLOYMENT == "true")
def doStageIfMergedToMaster = doStageIf.curry(scos.changeset.isMaster && env.DEV_DEPLOYMENT == "false")
def doStageIfRelease = doStageIf.curry(scos.changeset.isRelease)
node ('infrastructure') {
ansiColor('xterm') {
scos.doCheckoutStage()
doStageIfDeployingToDev('Deploy to Dev') {
deployTo(environment: 'dev', extraArgs: "--set image.tag=${env.DEV_IMAGE_TAG} --set image.pullPolicy=Always --recreate-pods")
}
doStageIfMergedToMaster('Deploy to Staging') {
deployTo(environment: 'staging')
scos.applyAndPushGitHubTag('staging')
}
doStageIfRelease('Deploy to Production') {
deployTo(environment: 'prod', internal: false)
scos.applyAndPushGitHubTag('prod')
}
}
}
def deployTo(params = [:]) {
def environment = params.get('environment')
if (environment == null) throw new IllegalArgumentException("environment must be specified")
def internal = params.get('internal', true)
def extraArgs = params.get('extraArgs', '')
scos.withEksCredentials(environment) {
def terraformOutputs = scos.terraformOutput(environment)
def subnets = terraformOutputs.public_subnets.value.join(/\\,/)
def allowInboundTrafficSG = terraformOutputs.allow_all_security_group.value
def rootIngressScheme = internal ? 'internal' : 'internet-facing'
def rootCertificateARN = terraformOutputs.root_tls_certificate_arn.value
def internalCertificateARN = terraformOutputs.tls_certificate_arn.value
def rootDnsZone = terraformOutputs.root_dns_zone_name.value
def internalDnsZone = terraformOutputs.internal_dns_zone_name.value
def rootWAFACLARN = terraformOutputs.eks_cluster_waf_acl_arn.value
sh("""#!/bin/bash
set -e
helm upgrade --install scos-joomla ./chart \
--namespace=joomla \
--values=joomla.yaml \
--set ingress.subnets="${subnets}" \
--set ingress.security_groups="${allowInboundTrafficSG}" \
--set ingress.root.enabled="true" \
--set ingress.root.scheme="${rootIngressScheme}" \
--set ingress.root.dns_zone="${rootDnsZone}" \
--set ingress.root.certificate_arns="${rootCertificateARN}" \
--set ingress.root.waf_acl_arn="${rootWAFACLARN}" \
--set ingress.internal.enabled="true" \
--set ingress.internal.dns_zone="${internalDnsZone}" \
--set ingress.internal.certificate_arns="${internalCertificateARN}" \
${extraArgs}
""".trim())
}
}