@@ -8,14 +8,17 @@ pipeline {
8
8
ansiColor(' xterm' )
9
9
}
10
10
environment {
11
- IMAGE = " nginx-proxy-manager"
11
+ IMAGE = ' nginx-proxy-manager'
12
12
BUILD_VERSION = getVersion()
13
- MAJOR_VERSION = " 2"
13
+ BUILD_COMMIT = getCommit()
14
+ MAJOR_VERSION = ' 3'
14
15
BRANCH_LOWER = " ${ BRANCH_NAME.toLowerCase().replaceAll('/', '-')} "
15
16
COMPOSE_PROJECT_NAME = " npm_${ BRANCH_LOWER} _${ BUILD_NUMBER} "
16
17
COMPOSE_FILE = ' docker/docker-compose.ci.yml'
17
18
COMPOSE_INTERACTIVE_NO_CLI = 1
18
19
BUILDX_NAME = " ${ COMPOSE_PROJECT_NAME} "
20
+ DOCS_BUCKET = ' jc21-npm-site-next' // TODO: change to prod when official
21
+ DOCS_CDN = ' E2Z0128EHS0Q23' // TODO: same
19
22
}
20
23
stages {
21
24
stage(' Environment' ) {
@@ -45,89 +48,67 @@ pipeline {
45
48
}
46
49
stage(' Versions' ) {
47
50
steps {
51
+ // Is this frontend version stuff still applicable?
48
52
sh ' cat frontend/package.json | jq --arg BUILD_VERSION "${BUILD_VERSION}" \' .version = $BUILD_VERSION\' | sponge frontend/package.json'
49
53
sh ' echo -e "\\ E[1;36mFrontend Version is:\\ E[1;33m $(cat frontend/package.json | jq -r .version)\\ E[0m"'
50
- sh ' cat backend/package.json | jq --arg BUILD_VERSION "${BUILD_VERSION}" \' .version = $BUILD_VERSION\' | sponge backend/package.json'
51
- sh ' echo -e "\\ E[1;36mBackend Version is:\\ E[1;33m $(cat backend/package.json | jq -r .version)\\ E[0m"'
52
54
sh ' sed -i -E "s/(version-)[0-9]+\\ .[0-9]+\\ .[0-9]+(-green)/\\ 1${BUILD_VERSION}\\ 2/" README.md'
53
55
}
54
56
}
55
57
}
56
58
}
57
59
stage(' Frontend' ) {
58
60
steps {
59
- sh ' ./scripts/frontend-build'
61
+ sh ' ./scripts/ci/frontend-build'
62
+ }
63
+ post {
64
+ always {
65
+ junit ' frontend/eslint.xml'
66
+ junit ' frontend/junit.xml'
67
+ }
60
68
}
61
69
}
62
70
stage(' Backend' ) {
63
71
steps {
64
- echo ' Checking Syntax ...'
65
- // See: https://github.com/yarnpkg/yarn/issues/3254
66
- sh ''' docker run --rm \\
67
- -v "$(pwd)/backend:/app" \\
68
- -v "$(pwd)/global:/app/global" \\
69
- -w /app \\
70
- node:latest \\
71
- sh -c "yarn install && yarn eslint . && rm -rf node_modules"
72
- '''
73
-
74
- echo ' Docker Build ...'
75
- sh ''' docker build --pull --no-cache --squash --compress \\
76
- -t "${IMAGE}:ci-${BUILD_NUMBER}" \\
77
- -f docker/Dockerfile \\
78
- --build-arg TARGETPLATFORM=linux/amd64 \\
79
- --build-arg BUILDPLATFORM=linux/amd64 \\
80
- --build-arg BUILD_VERSION="${BUILD_VERSION}" \\
81
- --build-arg BUILD_COMMIT="${BUILD_COMMIT}" \\
82
- --build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \\
83
- .
84
- '''
72
+ withCredentials([usernamePassword(credentialsId : ' oss-index-token' , passwordVariable : ' NANCY_TOKEN' , usernameVariable : ' NANCY_USER' )]) {
73
+ sh ''' docker build --pull --no-cache --squash --compress \\
74
+ -t ${IMAGE}:ci-${BUILD_NUMBER} \\
75
+ -f docker/Dockerfile \\
76
+ --build-arg TARGETPLATFORM=linux/amd64 \\
77
+ --build-arg BUILDPLATFORM=linux/amd64 \\
78
+ --build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \\
79
+ --build-arg BUILD_VERSION="${BUILD_VERSION}" \\
80
+ --build-arg BUILD_COMMIT="${BUILD_COMMIT}" \\
81
+ --build-arg SENTRY_DSN="${SENTRY_DSN:-}" \\
82
+ --build-arg GOPROXY="${GOPROXY:-}" \\
83
+ --build-arg GOPRIVATE="${GOPRIVATE:-}" \\
84
+ --build-arg NANCY_USER="${NANCY_USER}" \\
85
+ --build-arg NANCY_TOKEN="${NANCY_TOKEN}" \\
86
+ .
87
+ '''
88
+ }
85
89
}
86
90
}
87
- stage(' Integration Tests Sqlite' ) {
88
- steps {
89
- // Bring up a stack
90
- sh ' docker-compose up -d fullstack-sqlite'
91
- sh ' ./scripts/wait-healthy $(docker-compose ps -q fullstack-sqlite) 120'
92
-
93
- // Run tests
94
- sh ' rm -rf test/results'
95
- sh ' docker-compose up cypress-sqlite'
96
- // Get results
97
- sh ' docker cp -L "$(docker-compose ps -q cypress-sqlite):/test/results" test/'
98
- }
99
- post {
100
- always {
101
- // Dumps to analyze later
102
- sh ' mkdir -p debug'
103
- sh ' docker-compose logs fullstack-sqlite | gzip > debug/docker_fullstack_sqlite.log.gz'
104
- sh ' docker-compose logs db | gzip > debug/docker_db.log.gz'
105
- // Cypress videos and screenshot artifacts
106
- dir(path : ' test/results' ) {
107
- archiveArtifacts allowEmptyArchive : true , artifacts : ' **/*' , excludes : ' **/*.xml'
108
- }
109
- junit ' test/results/junit/*'
91
+ stage(' Test' ) {
92
+ when {
93
+ not {
94
+ equals expected : ' UNSTABLE' , actual : currentBuild. result
110
95
}
111
96
}
112
- }
113
- stage(' Integration Tests Mysql' ) {
114
97
steps {
115
98
// Bring up a stack
116
- sh ' docker-compose up -d fullstack-mysql'
117
- sh ' ./scripts/wait-healthy $(docker-compose ps -q fullstack-mysql) 120'
118
-
99
+ sh ' docker-compose up -d fullstack'
100
+ sh ' ./scripts/wait-healthy $(docker-compose ps -q fullstack) 120'
119
101
// Run tests
120
102
sh ' rm -rf test/results'
121
- sh ' docker-compose up cypress-mysql '
103
+ sh ' docker-compose up cypress'
122
104
// Get results
123
- sh ' docker cp -L "$(docker-compose ps -q cypress-mysql ):/test/results" test/'
105
+ sh ' docker cp -L "$(docker-compose ps -q cypress):/test/results" test/'
124
106
}
125
107
post {
126
108
always {
127
109
// Dumps to analyze later
128
110
sh ' mkdir -p debug'
129
- sh ' docker-compose logs fullstack-mysql | gzip > debug/docker_fullstack_mysql.log.gz'
130
- sh ' docker-compose logs db | gzip > debug/docker_db.log.gz'
111
+ sh ' docker-compose logs fullstack | gzip > debug/docker_fullstack.log.gz'
131
112
// Cypress videos and screenshot artifacts
132
113
dir(path : ' test/results' ) {
133
114
archiveArtifacts allowEmptyArchive : true , artifacts : ' **/*' , excludes : ' **/*.xml'
@@ -148,28 +129,41 @@ pipeline {
148
129
sh ' yarn build'
149
130
}
150
131
132
+ // API Docs:
133
+ sh ' docker-compose exec -T fullstack curl -s --output /temp-docs/api-schema.json "http://fullstack:81/api/schema"'
134
+ sh ' mkdir -p "docs/.vuepress/dist/api"'
135
+ sh ' mv docs/api-schema.json docs/.vuepress/dist/api/'
136
+
151
137
dir(path : ' docs/.vuepress/dist' ) {
152
138
sh ' tar -czf ../../docs.tgz *'
153
139
}
154
140
155
141
archiveArtifacts(artifacts : ' docs/docs.tgz' , allowEmptyArchive : false )
156
142
}
157
143
}
144
+ /*
158
145
stage('MultiArch Build') {
159
146
when {
160
- not {
161
- equals expected : ' UNSTABLE' , actual : currentBuild. result
147
+ allOf {
148
+ branch 'master'
149
+ not {
150
+ equals expected: 'UNSTABLE', actual: currentBuild.result
151
+ }
162
152
}
163
153
}
164
154
steps {
165
- withCredentials([usernamePassword(credentialsId : ' jc21-dockerhub' , passwordVariable : ' dpass' , usernameVariable : ' duser' )]) {
166
- // Docker Login
167
- sh " docker login -u '${ duser} ' -p '${ dpass} '"
168
- // Buildx with push from cache
169
- sh " ./scripts/buildx --push ${ BUILDX_PUSH_TAGS} "
155
+ withCredentials([string(credentialsId: 'npm-sentry-dsn', variable: 'SENTRY_DSN')]) {
156
+ withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
157
+ sh "docker login -u '${duser}' -p '${dpass}'"
158
+ // Buildx to local files
159
+ // sh './scripts/buildx -o type=local,dest=docker-build'
160
+ // Buildx to with push
161
+ sh "./scripts/buildx --push ${BUILDX_PUSH_TAGS}"
162
+ }
170
163
}
171
164
}
172
165
}
166
+ */
173
167
stage(' Docs Deploy' ) {
174
168
when {
175
169
allOf {
@@ -183,7 +177,7 @@ pipeline {
183
177
withCredentials([[$class : ' AmazonWebServicesCredentialsBinding' , accessKeyVariable : ' AWS_ACCESS_KEY_ID' , credentialsId : ' npm-s3-docs' , secretKeyVariable : ' AWS_SECRET_ACCESS_KEY' ]]) {
184
178
sh """ docker run --rm \\
185
179
--name \$ {COMPOSE_PROJECT_NAME}-docs-upload \\
186
- -e S3_BUCKET=jc21-npm-site \\
180
+ -e S3_BUCKET=$D OCS_BUCKET \\
187
181
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \\
188
182
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \\
189
183
-v \$ (pwd):/app \\
@@ -197,7 +191,7 @@ pipeline {
197
191
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \\
198
192
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \\
199
193
jc21/ci-tools \\
200
- aws cloudfront create-invalidation --distribution-id EN1G6DEWZUTDT --paths '/*'
194
+ aws cloudfront create-invalidation --distribution-id $D OCS_CDN --paths '/*'
201
195
"""
202
196
}
203
197
}
@@ -213,16 +207,50 @@ pipeline {
213
207
}
214
208
steps {
215
209
script {
216
- def comment = pullRequest. comment(" This is an automated message from CI:\n\n Docker Image for build ${ BUILD_NUMBER} is available on [DockerHub](https://cloud.docker.com/repository/docker/jc21/${ IMAGE} ) as `jc21/${ IMAGE} :github-${ BRANCH_LOWER} `\n\n **Note:** ensure you backup your NPM instance before testing this PR image! Especially if this PR contains database changes." )
210
+ def comment = pullRequest. comment(" This is an automated message from CI:\n\n Docker Image for build ${ BUILD_NUMBER} is available on [DockerHub](https://cloud.docker.com/repository/docker/jc21/${ IMAGE} ) as `jc21/${ IMAGE} :git-3-${ BRANCH_LOWER} `\n\n **Note:** ensure you backup your NPM instance before testing this PR image! Especially if this PR contains database changes." )
211
+ }
212
+ }
213
+ }
214
+ stage(' Artifacts' ) {
215
+ when {
216
+ allOf {
217
+ branch ' master'
218
+ not {
219
+ equals expected : ' UNSTABLE' , actual : currentBuild. result
220
+ }
221
+ }
222
+ }
223
+ steps {
224
+ sh ' mkdir -p artifacts'
225
+ // Docs
226
+ dir(path : ' docs/.vuepress/dist' ) {
227
+ sh ' zip -qr ../../../artifacts/docs.zip *'
228
+ }
229
+ // Multiarch builds
230
+ /*
231
+ dir(path: 'docker-build/linux_amd64/app') {
232
+ sh 'zip -qr ../../../artifacts/linux_amd64.zip *'
233
+ }
234
+ dir(path: 'docker-build/linux_arm64/app') {
235
+ sh 'zip -qr ../../../artifacts/linux_arm64.zip *'
236
+ }
237
+ dir(path: 'docker-build/linux_arm_v7/app') {
238
+ sh 'zip -qr ../../../artifacts/linux_arm_v7.zip *'
239
+ }
240
+ **/
241
+ // Archive them
242
+ dir(path : ' artifacts' ) {
243
+ archiveArtifacts artifacts : ' **/*'
217
244
}
218
245
}
219
246
}
220
247
}
221
248
post {
222
249
always {
223
250
sh ' docker-compose down --rmi all --remove-orphans --volumes -t 30'
251
+ sh ' ./scripts/build-cleanup'
224
252
sh ' echo Reverting ownership'
225
- sh ' docker run --rm -v $(pwd):/data jc21/ci-tools chown -R $(id -u):$(id -g) /data'
253
+ sh ' docker run --rm -v $(pwd):/data node:latest chown -R " $(id -u):$(id -g)" /data'
226
254
}
227
255
success {
228
256
juxtapose event : ' success'
0 commit comments