-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
163 lines (154 loc) · 4.76 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
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
properties([pipelineTriggers([githubPush()])])
pipeline {
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 30, unit: 'MINUTES')
}
agent {
kubernetes {
inheritFrom 'kaniko-slim'
containerTemplates([
containerTemplate(name: 'postgres', image: "flowcommerce/registry-postgresql:latest", alwaysPullImage: true, resourceRequestMemory: '1Gi'),
containerTemplate(name: 'play', image: "flowdocker/play_builder:latest-java17", alwaysPullImage: true, resourceRequestMemory: '2Gi', command: 'cat', ttyEnabled: true)
])
}
}
environment {
ORG = 'flowcommerce'
}
stages {
stage('Checkout') {
steps {
checkoutWithTags scm
script {
VERSION = new flowSemver().calculateSemver() //requires checkout
}
}
}
stage('Commit SemVer tag') {
when { branch 'main' }
steps {
script {
new flowSemver().commitSemver(VERSION)
}
}
}
stage('Display Helm Diff') {
when {
allOf {
not { branch 'main' }
changeRequest()
}
}
steps {
script {
container('helm') {
helmCommonDiff(['registry'])
}
}
}
}
stage("Build, Deploy, SBT test") {
stages {
stage('Build and deploy') {
when { branch 'main' }
stages {
stage('Build and push docker image release') {
stages {
stage("parallel image builds") {
parallel {
stage("Build x86_64/amd64 registry image") {
steps {
container('kaniko') {
script {
String semversion = VERSION.printable()
imageBuild(
orgName: 'flowcommerce',
serviceName: 'registry',
platform: 'amd64',
dockerfilePath: '/Dockerfile',
semver: semversion
)
}
}
}
}
stage("Build arm64 registry image") {
agent {
kubernetes {
label 'registry-arm64'
inheritFrom 'kaniko-slim-arm64'
}
}
steps {
container('kaniko') {
script {
String semversion = VERSION.printable()
imageBuild(
orgName: 'flowcommerce',
serviceName: 'registry',
platform: 'arm64',
dockerfilePath: '/Dockerfile',
semver: semversion
)
}
}
}
}
}
}
}
}
stage('manifest tool step for registry docker images') {
steps {
container('kaniko') {
script {
semver = VERSION.printable()
String templateName = "registry-ARCH:${semver}"
String targetName = "registry:${semver}"
String orgName = "flowcommerce"
String jenkinsAgentArch = "amd64"
manifestTool(templateName, targetName, orgName, jenkinsAgentArch)
}
}
}
}
stage('Deploy registry') {
when { branch 'main' }
steps {
script {
container('helm') {
new helmCommonDeploy().deploy('registry', 'production', VERSION.printable())
}
}
}
}
}
}
stage('SBT Test') {
steps {
container('play') {
script {
try {
sh '''
echo "$(date) - waiting for database to start"
until pg_isready -h localhost
do
sleep 10
done
'''
sh 'sbt clean flowLint coverage test scalafmtSbtCheck scalafmtCheck'
sh 'sbt coverageAggregate'
}
finally {
postSbtReport()
}
}
}
}
}
}
}
}
}