@sharadtech/infralytiqs-sdk 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/buildScripts/Jenkinsfile.deploy +317 -49
- package/clients/publicis/ps/README.md +184 -0
- package/clients/publicis/ps/package-lock.json +815 -0
- package/clients/publicis/ps/package.json +23 -0
- package/clients/publicis/ps/rollup.config.mjs +28 -0
- package/clients/publicis/ps/src/index.js +2882 -0
- package/dist/infralytiqs.js +201 -1
- package/dist/infralytiqs.min.js +2 -2
- package/package.json +1 -1
- package/src/bootstrapLoader.ts +94 -0
- package/src/index.ts +46 -0
- package/src/token.ts +79 -0
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
// =============================================================================
|
|
2
2
|
// Infralytiqs SDK — DEPLOY Jenkinsfile
|
|
3
3
|
// -----------------------------------------------------------------------------
|
|
4
|
-
// Pipeline performs the deploy flow:
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
4
|
+
// Pipeline performs the deploy flow for two distinct artifacts:
|
|
5
|
+
//
|
|
6
|
+
// A) The shared Infralytiqs SDK (sourced from npmjs.com).
|
|
7
|
+
// Uploaded to: s3://infralytiqs/cdn/infralytiqs.min.js
|
|
8
|
+
// Served via : https://assets.infralytiqs.com/cdn/infralytiqs.min.js
|
|
9
|
+
//
|
|
10
|
+
// B) Per-client bootstraps (built directly from this git repository under
|
|
11
|
+
// clients/<vendor>/<app>). Currently the only client wired in is:
|
|
12
|
+
//
|
|
13
|
+
// clients/publicis/ps -> s3://infralytiqs/cl/publicis/ps/infralytiqs-bootstrap.min.js
|
|
14
|
+
// https://assets.infralytiqs.com/cl/publicis/ps/infralytiqs-bootstrap.min.js
|
|
15
|
+
//
|
|
16
|
+
// Additional clients can be wired in by adding another build/upload/
|
|
17
|
+
// verify stage trio with its own boolean job parameter.
|
|
18
|
+
//
|
|
19
|
+
// Per-artifact stages can be toggled independently from the build form via
|
|
20
|
+
// the DEPLOY_SDK and DEPLOY_CLIENT_PUBLICIS_PS boolean job parameters.
|
|
9
21
|
//
|
|
10
22
|
// Required Jenkins credentials:
|
|
11
|
-
// - aws-infralytiqs-deploy :
|
|
12
|
-
//
|
|
13
|
-
//
|
|
23
|
+
// - aws-infralytiqs-deploy : "Username with password" credential where
|
|
24
|
+
// username = AWS Access Key ID and
|
|
25
|
+
// password = AWS Secret Access Key.
|
|
26
|
+
// (We don't need the AWS Credentials plugin —
|
|
27
|
+
// we just bind it as a username/password and
|
|
28
|
+
// export the standard AWS_* env vars ourselves.)
|
|
14
29
|
//
|
|
15
30
|
// Required Jenkins plugins:
|
|
16
31
|
// - Pipeline Utility Steps
|
|
17
32
|
// - Credentials Binding
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// - NodeJS Plugin (only if you want managed npm/node — see TOOLS
|
|
21
|
-
// block below; otherwise the agent must already
|
|
22
|
-
// have node + npm + curl + aws on PATH).
|
|
33
|
+
// (No AWS Credentials plugin or NodeJS tool installation is needed — we
|
|
34
|
+
// download portable Node and AWS CLI v2 into the workspace at runtime.)
|
|
23
35
|
// =============================================================================
|
|
24
36
|
|
|
25
37
|
pipeline {
|
|
@@ -29,21 +41,31 @@ pipeline {
|
|
|
29
41
|
string(
|
|
30
42
|
name: 'DEPLOY_VERSION',
|
|
31
43
|
defaultValue: '1.0.0',
|
|
32
|
-
description: 'Release version available on npmjs.com (e.g. "1.0.1") to deploy to S3 / CDN.'
|
|
44
|
+
description: 'Release version available on npmjs.com (e.g. "1.0.1") to deploy to S3 / CDN. Only used when DEPLOY_SDK is checked.'
|
|
45
|
+
)
|
|
46
|
+
booleanParam(
|
|
47
|
+
name: 'DEPLOY_SDK',
|
|
48
|
+
defaultValue: true,
|
|
49
|
+
description: 'Fetch the released SDK from npmjs.com and upload it to s3://infralytiqs/cdn/infralytiqs.min.js'
|
|
50
|
+
)
|
|
51
|
+
booleanParam(
|
|
52
|
+
name: 'DEPLOY_CLIENT_PUBLICIS_PS',
|
|
53
|
+
defaultValue: true,
|
|
54
|
+
description: 'Build clients/publicis/ps from THIS repository and upload its minified bootstrap to s3://infralytiqs/cl/publicis/ps/infralytiqs-bootstrap.min.js'
|
|
33
55
|
)
|
|
34
56
|
}
|
|
35
57
|
|
|
36
58
|
options {
|
|
37
59
|
buildDiscarder(logRotator(numToKeepStr: '30'))
|
|
38
60
|
disableConcurrentBuilds()
|
|
39
|
-
timeout(time:
|
|
61
|
+
timeout(time: 30, unit: 'MINUTES')
|
|
40
62
|
}
|
|
41
63
|
|
|
42
64
|
// -------------------------------------------------------------------------
|
|
43
65
|
// Pipeline-wide configuration — adjust per environment.
|
|
44
66
|
// -------------------------------------------------------------------------
|
|
45
67
|
environment {
|
|
46
|
-
// ---- npm registry (source of artifact) ----
|
|
68
|
+
// ---- npm registry (source of SDK artifact) ----
|
|
47
69
|
NPM_REGISTRY = 'https://registry.npmjs.org/'
|
|
48
70
|
NPM_PACKAGE_NAME = '@sharadtech/infralytiqs-sdk'
|
|
49
71
|
|
|
@@ -55,22 +77,32 @@ pipeline {
|
|
|
55
77
|
SDK_FILENAME_MIN = 'infralytiqs.min.js'
|
|
56
78
|
SDK_FILENAME_UNMIN = 'infralytiqs.js'
|
|
57
79
|
|
|
58
|
-
// ---- S3 destination ----
|
|
59
|
-
S3_BUCKET = '
|
|
60
|
-
S3_KEY_PREFIX = '
|
|
80
|
+
// ---- S3 destination (shared SDK) ----
|
|
81
|
+
S3_BUCKET = 'infralytiqs' // <-- adjust
|
|
82
|
+
S3_KEY_PREFIX = 'cdn' // <-- adjust
|
|
61
83
|
S3_OBJECT_NAME = 'infralytiqs.min.js' // final filename in S3
|
|
62
|
-
AWS_REGION = '
|
|
84
|
+
AWS_REGION = 'eu-west-2'
|
|
63
85
|
AWS_CREDENTIALS_ID = 'aws-infralytiqs-deploy'
|
|
64
86
|
|
|
65
|
-
// ---- Object metadata ----
|
|
87
|
+
// ---- Object metadata (shared by every uploaded artifact) ----
|
|
66
88
|
S3_CONTENT_TYPE = 'application/javascript; charset=utf-8'
|
|
67
89
|
S3_CACHE_CONTROL = 'public, max-age=300'
|
|
68
90
|
|
|
69
91
|
// ---- CDN verification ----
|
|
70
92
|
CDN_BASE_URL = 'https://assets.infralytiqs.com'
|
|
71
|
-
CDN_VERIFY_PATH = '
|
|
93
|
+
CDN_VERIFY_PATH = 'cdn/infralytiqs.min.js'
|
|
72
94
|
CDN_VERIFY_RETRIES = '6' // number of attempts
|
|
73
95
|
CDN_VERIFY_SLEEP_SEC = '10' // delay between attempts
|
|
96
|
+
|
|
97
|
+
// ---- clients/publicis/ps (client-specific bootstrap) ----
|
|
98
|
+
// The git repository is checked out into this subdirectory by the
|
|
99
|
+
// "Checkout Source" stage so it doesn't collide with the npm artifact
|
|
100
|
+
// tarball or the AWS CLI binaries downloaded into the workspace root.
|
|
101
|
+
REPO_SRC_DIR = 'repo-src'
|
|
102
|
+
CLIENT_PS_REL_DIR = 'clients/publicis/ps'
|
|
103
|
+
CLIENT_PS_BOOTSTRAP_MIN = 'infralytiqs-bootstrap.min.js'
|
|
104
|
+
CLIENT_PS_S3_KEY_PREFIX = 'cl/publicis/ps'
|
|
105
|
+
CLIENT_PS_CDN_VERIFY_PATH = 'cl/publicis/ps/infralytiqs-bootstrap.min.js'
|
|
74
106
|
}
|
|
75
107
|
|
|
76
108
|
// If you use the Jenkins NodeJS plugin, uncomment and set the tool name:
|
|
@@ -79,18 +111,33 @@ pipeline {
|
|
|
79
111
|
stages {
|
|
80
112
|
|
|
81
113
|
// ---------------------------------------------------------------------
|
|
82
|
-
stage('
|
|
114
|
+
stage('Init Workspace') {
|
|
83
115
|
steps {
|
|
84
116
|
// Workspace Cleanup plugin not installed on this Jenkins —
|
|
85
|
-
// use deleteDir() to wipe the workspace.
|
|
117
|
+
// use deleteDir() to wipe the workspace before every build.
|
|
86
118
|
deleteDir()
|
|
87
119
|
script {
|
|
88
|
-
if (!params.
|
|
89
|
-
error "
|
|
120
|
+
if (!params.DEPLOY_SDK && !params.DEPLOY_CLIENT_PUBLICIS_PS) {
|
|
121
|
+
error "Nothing to do: both DEPLOY_SDK and DEPLOY_CLIENT_PUBLICIS_PS are unchecked."
|
|
122
|
+
}
|
|
123
|
+
def labelParts = []
|
|
124
|
+
if (params.DEPLOY_SDK) {
|
|
125
|
+
if (!params.DEPLOY_VERSION?.trim()) {
|
|
126
|
+
error "DEPLOY_VERSION is required when DEPLOY_SDK is checked."
|
|
127
|
+
}
|
|
128
|
+
labelParts << "sdk:${params.DEPLOY_VERSION}"
|
|
90
129
|
}
|
|
91
|
-
|
|
130
|
+
if (params.DEPLOY_CLIENT_PUBLICIS_PS) {
|
|
131
|
+
labelParts << 'publicis/ps'
|
|
132
|
+
}
|
|
133
|
+
currentBuild.displayName = "#${env.BUILD_NUMBER} • ${labelParts.join(' + ')}"
|
|
92
134
|
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
93
137
|
|
|
138
|
+
// ---------------------------------------------------------------------
|
|
139
|
+
stage('Setup Node') {
|
|
140
|
+
steps {
|
|
94
141
|
// Bring our own portable Node.js (the agent has no global Node).
|
|
95
142
|
sh '''
|
|
96
143
|
set -eu
|
|
@@ -115,7 +162,13 @@ pipeline {
|
|
|
115
162
|
env.NODE_HOME = "${env.WORKSPACE}/.tools/node-v${env.NODE_VERSION}-${env.NODE_PLATFORM}"
|
|
116
163
|
env.PATH = "${env.NODE_HOME}/bin:${env.PATH}"
|
|
117
164
|
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
118
167
|
|
|
168
|
+
// ---------------------------------------------------------------------
|
|
169
|
+
stage('Fetch Released SDK (npm)') {
|
|
170
|
+
when { expression { return params.DEPLOY_SDK } }
|
|
171
|
+
steps {
|
|
119
172
|
sh '''
|
|
120
173
|
set -eu
|
|
121
174
|
echo "Node : $(node --version)"
|
|
@@ -150,37 +203,149 @@ pipeline {
|
|
|
150
203
|
// Sanity-check the embedded version banner before uploading.
|
|
151
204
|
def header = sh(script: "head -c 1024 ${minPath}", returnStdout: true)
|
|
152
205
|
if (!header.contains(params.DEPLOY_VERSION)) {
|
|
153
|
-
error "Fetched artifact does NOT contain expected version '${params.DEPLOY_VERSION}' in its banner. Aborting deploy."
|
|
206
|
+
error "Fetched SDK artifact does NOT contain expected version '${params.DEPLOY_VERSION}' in its banner. Aborting deploy."
|
|
154
207
|
}
|
|
155
|
-
echo "Verified fetched artifact contains version banner v${params.DEPLOY_VERSION}."
|
|
208
|
+
echo "Verified fetched SDK artifact contains version banner v${params.DEPLOY_VERSION}."
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// ---------------------------------------------------------------------
|
|
214
|
+
stage('Checkout Source (client builds)') {
|
|
215
|
+
when { expression { return params.DEPLOY_CLIENT_PUBLICIS_PS } }
|
|
216
|
+
steps {
|
|
217
|
+
// The repository is checked out into a sub-folder so it
|
|
218
|
+
// doesn't collide with the npm pack output (artifact/) or
|
|
219
|
+
// the AWS CLI binaries (.tools/) we drop into the workspace
|
|
220
|
+
// root. The Jenkins SCM config of this job (URL + branch +
|
|
221
|
+
// credentials) is reused verbatim.
|
|
222
|
+
dir("${env.REPO_SRC_DIR}") {
|
|
223
|
+
checkout scm
|
|
224
|
+
sh 'git --no-pager log -1 --oneline'
|
|
156
225
|
}
|
|
157
226
|
}
|
|
158
227
|
}
|
|
159
228
|
|
|
160
229
|
// ---------------------------------------------------------------------
|
|
161
|
-
stage('
|
|
230
|
+
stage('Build Client — publicis/ps') {
|
|
231
|
+
when { expression { return params.DEPLOY_CLIENT_PUBLICIS_PS } }
|
|
162
232
|
steps {
|
|
163
|
-
|
|
164
|
-
|
|
233
|
+
sh '''
|
|
234
|
+
set -eu
|
|
235
|
+
cd "${REPO_SRC_DIR}/${CLIENT_PS_REL_DIR}"
|
|
236
|
+
echo "Building client bootstrap in $(pwd) ..."
|
|
237
|
+
# `npm ci` requires package-lock.json; fall back to install
|
|
238
|
+
# for a fresh checkout that doesn't carry one yet.
|
|
239
|
+
if [ -f package-lock.json ]; then
|
|
240
|
+
npm ci --no-audit --no-fund
|
|
241
|
+
else
|
|
242
|
+
npm install --no-audit --no-fund
|
|
243
|
+
fi
|
|
244
|
+
npm run build
|
|
245
|
+
ls -la dist
|
|
246
|
+
'''
|
|
247
|
+
|
|
248
|
+
script {
|
|
249
|
+
def relMin = "${env.REPO_SRC_DIR}/${env.CLIENT_PS_REL_DIR}/dist/${env.CLIENT_PS_BOOTSTRAP_MIN}"
|
|
250
|
+
if (!fileExists(relMin)) {
|
|
251
|
+
error "Build did not produce expected client bootstrap: ${relMin}"
|
|
252
|
+
}
|
|
253
|
+
env.LOCAL_CLIENT_PS_MIN_PATH = relMin
|
|
254
|
+
archiveArtifacts artifacts: "${env.REPO_SRC_DIR}/${env.CLIENT_PS_REL_DIR}/dist/*.js",
|
|
255
|
+
fingerprint: true,
|
|
256
|
+
onlyIfSuccessful: true
|
|
257
|
+
echo "Built client bootstrap: ${relMin}"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// ---------------------------------------------------------------------
|
|
263
|
+
stage('Setup AWS CLI') {
|
|
264
|
+
steps {
|
|
265
|
+
// Download a portable AWS CLI v2 distribution into the
|
|
266
|
+
// workspace so the pipeline doesn't depend on aws being
|
|
267
|
+
// pre-installed on the agent. We invoke the bundled
|
|
268
|
+
// aws/dist/aws binary directly (no system-wide install
|
|
269
|
+
// step is needed, no root, no PATH writes outside $WORKSPACE).
|
|
270
|
+
sh '''
|
|
271
|
+
set -eu
|
|
272
|
+
AWS_CLI_DIR="${WORKSPACE}/.tools/aws-cli"
|
|
273
|
+
AWS_CLI_BIN="${AWS_CLI_DIR}/aws/dist/aws"
|
|
274
|
+
if [ ! -x "${AWS_CLI_BIN}" ]; then
|
|
275
|
+
mkdir -p "${WORKSPACE}/.tools"
|
|
276
|
+
echo "Downloading AWS CLI v2 ..."
|
|
277
|
+
curl -fSL --retry 3 --retry-delay 2 \
|
|
278
|
+
"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" \
|
|
279
|
+
-o "${WORKSPACE}/.tools/awscliv2.zip"
|
|
280
|
+
rm -rf "${AWS_CLI_DIR}"
|
|
281
|
+
mkdir -p "${AWS_CLI_DIR}"
|
|
282
|
+
# The agent doesn't necessarily have `unzip`. Fall back
|
|
283
|
+
# in order to: unzip -> jar (JDK ships with the Jenkins
|
|
284
|
+
# agent) -> python3 zipfile module. At least one of
|
|
285
|
+
# these is available on essentially any Linux Jenkins
|
|
286
|
+
# agent.
|
|
287
|
+
cd "${AWS_CLI_DIR}"
|
|
288
|
+
if command -v unzip >/dev/null 2>&1; then
|
|
289
|
+
echo "Extracting with unzip ..."
|
|
290
|
+
unzip -q "${WORKSPACE}/.tools/awscliv2.zip"
|
|
291
|
+
elif command -v jar >/dev/null 2>&1; then
|
|
292
|
+
echo "Extracting with jar ..."
|
|
293
|
+
jar -xf "${WORKSPACE}/.tools/awscliv2.zip"
|
|
294
|
+
elif command -v python3 >/dev/null 2>&1; then
|
|
295
|
+
echo "Extracting with python3 zipfile ..."
|
|
296
|
+
python3 -c "import zipfile,sys; zipfile.ZipFile(sys.argv[1]).extractall('.')" \
|
|
297
|
+
"${WORKSPACE}/.tools/awscliv2.zip"
|
|
298
|
+
else
|
|
299
|
+
echo "ERROR: agent is missing all of: unzip, jar (JDK), python3" >&2
|
|
300
|
+
exit 1
|
|
301
|
+
fi
|
|
302
|
+
cd "${WORKSPACE}"
|
|
303
|
+
# The bundled aws/dist/aws (and aws/install) binaries
|
|
304
|
+
# may lose their +x bit through some extractors.
|
|
305
|
+
chmod +x "${AWS_CLI_BIN}" "${AWS_CLI_DIR}/aws/install" 2>/dev/null || true
|
|
306
|
+
rm -f "${WORKSPACE}/.tools/awscliv2.zip"
|
|
307
|
+
fi
|
|
308
|
+
"${AWS_CLI_BIN}" --version
|
|
309
|
+
'''
|
|
310
|
+
script {
|
|
311
|
+
env.AWS_CLI_BIN = "${env.WORKSPACE}/.tools/aws-cli/aws/dist/aws"
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// ---------------------------------------------------------------------
|
|
317
|
+
stage('Upload SDK') {
|
|
318
|
+
when { expression { return params.DEPLOY_SDK } }
|
|
319
|
+
steps {
|
|
320
|
+
// The credential is stored as "Username with password":
|
|
321
|
+
// username = AWS Access Key ID
|
|
322
|
+
// password = AWS Secret Access Key
|
|
323
|
+
// (so we don't need the AWS Credentials plugin).
|
|
324
|
+
withCredentials([usernamePassword(
|
|
165
325
|
credentialsId: env.AWS_CREDENTIALS_ID,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
]
|
|
326
|
+
usernameVariable: 'AWS_ACCESS_KEY_ID',
|
|
327
|
+
passwordVariable: 'AWS_SECRET_ACCESS_KEY'
|
|
328
|
+
)]) {
|
|
169
329
|
sh '''
|
|
170
330
|
set -eu
|
|
171
|
-
|
|
331
|
+
export AWS_DEFAULT_REGION="${AWS_REGION}"
|
|
332
|
+
# Make sure curl/git proxy or other AWS_* leftovers don't
|
|
333
|
+
# interfere with the credentials we just bound.
|
|
334
|
+
unset AWS_SESSION_TOKEN || true
|
|
335
|
+
|
|
336
|
+
"${AWS_CLI_BIN}" --version
|
|
172
337
|
|
|
173
338
|
S3_TARGET="s3://${S3_BUCKET}/${S3_KEY_PREFIX}/${S3_OBJECT_NAME}"
|
|
174
339
|
echo "Uploading ${LOCAL_SDK_MIN_PATH} -> ${S3_TARGET}"
|
|
175
340
|
|
|
176
|
-
|
|
341
|
+
"${AWS_CLI_BIN}" s3 cp "${LOCAL_SDK_MIN_PATH}" "${S3_TARGET}" \
|
|
177
342
|
--region "${AWS_REGION}" \
|
|
178
343
|
--content-type "${S3_CONTENT_TYPE}" \
|
|
179
344
|
--cache-control "${S3_CACHE_CONTROL}" \
|
|
180
345
|
--metadata "sdk-version=${DEPLOY_VERSION}"
|
|
181
346
|
|
|
182
347
|
echo "S3 head-object verification:"
|
|
183
|
-
|
|
348
|
+
"${AWS_CLI_BIN}" s3api head-object \
|
|
184
349
|
--region "${AWS_REGION}" \
|
|
185
350
|
--bucket "${S3_BUCKET}" \
|
|
186
351
|
--key "${S3_KEY_PREFIX}/${S3_OBJECT_NAME}"
|
|
@@ -190,7 +355,8 @@ pipeline {
|
|
|
190
355
|
}
|
|
191
356
|
|
|
192
357
|
// ---------------------------------------------------------------------
|
|
193
|
-
stage('Verify') {
|
|
358
|
+
stage('Verify SDK on CDN') {
|
|
359
|
+
when { expression { return params.DEPLOY_SDK } }
|
|
194
360
|
steps {
|
|
195
361
|
sh '''
|
|
196
362
|
set -eu
|
|
@@ -227,29 +393,131 @@ pipeline {
|
|
|
227
393
|
}
|
|
228
394
|
}
|
|
229
395
|
|
|
396
|
+
// ---------------------------------------------------------------------
|
|
397
|
+
stage('Upload Client — publicis/ps') {
|
|
398
|
+
when { expression { return params.DEPLOY_CLIENT_PUBLICIS_PS } }
|
|
399
|
+
steps {
|
|
400
|
+
withCredentials([usernamePassword(
|
|
401
|
+
credentialsId: env.AWS_CREDENTIALS_ID,
|
|
402
|
+
usernameVariable: 'AWS_ACCESS_KEY_ID',
|
|
403
|
+
passwordVariable: 'AWS_SECRET_ACCESS_KEY'
|
|
404
|
+
)]) {
|
|
405
|
+
sh '''
|
|
406
|
+
set -eu
|
|
407
|
+
export AWS_DEFAULT_REGION="${AWS_REGION}"
|
|
408
|
+
unset AWS_SESSION_TOKEN || true
|
|
409
|
+
|
|
410
|
+
"${AWS_CLI_BIN}" --version
|
|
411
|
+
|
|
412
|
+
S3_TARGET="s3://${S3_BUCKET}/${CLIENT_PS_S3_KEY_PREFIX}/${CLIENT_PS_BOOTSTRAP_MIN}"
|
|
413
|
+
echo "Uploading ${LOCAL_CLIENT_PS_MIN_PATH} -> ${S3_TARGET}"
|
|
414
|
+
|
|
415
|
+
"${AWS_CLI_BIN}" s3 cp "${LOCAL_CLIENT_PS_MIN_PATH}" "${S3_TARGET}" \
|
|
416
|
+
--region "${AWS_REGION}" \
|
|
417
|
+
--content-type "${S3_CONTENT_TYPE}" \
|
|
418
|
+
--cache-control "${S3_CACHE_CONTROL}" \
|
|
419
|
+
--metadata "client=publicis-ps build-number=${BUILD_NUMBER}"
|
|
420
|
+
|
|
421
|
+
echo "S3 head-object verification:"
|
|
422
|
+
"${AWS_CLI_BIN}" s3api head-object \
|
|
423
|
+
--region "${AWS_REGION}" \
|
|
424
|
+
--bucket "${S3_BUCKET}" \
|
|
425
|
+
--key "${CLIENT_PS_S3_KEY_PREFIX}/${CLIENT_PS_BOOTSTRAP_MIN}"
|
|
426
|
+
'''
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// ---------------------------------------------------------------------
|
|
432
|
+
stage('Verify Client — publicis/ps on CDN') {
|
|
433
|
+
when { expression { return params.DEPLOY_CLIENT_PUBLICIS_PS } }
|
|
434
|
+
steps {
|
|
435
|
+
sh '''
|
|
436
|
+
set -eu
|
|
437
|
+
CDN_URL="${CDN_BASE_URL}/${CLIENT_PS_CDN_VERIFY_PATH}"
|
|
438
|
+
LOCAL_BANNER=$(head -n 1 "${LOCAL_CLIENT_PS_MIN_PATH}" | tr -d "\n")
|
|
439
|
+
echo "Verifying CDN URL: ${CDN_URL}"
|
|
440
|
+
echo "Expected banner : ${LOCAL_BANNER}"
|
|
441
|
+
|
|
442
|
+
i=1
|
|
443
|
+
while [ "${i}" -le "${CDN_VERIFY_RETRIES}" ]; do
|
|
444
|
+
STATUS=$(curl -sS -o /tmp/client-ps-cdn.js -w "%{http_code}" \
|
|
445
|
+
"${CDN_URL}?cb=$(date +%s)-${BUILD_NUMBER}-${i}" || echo "000")
|
|
446
|
+
|
|
447
|
+
if [ "${STATUS}" = "200" ]; then
|
|
448
|
+
CDN_BANNER=$(head -n 1 /tmp/client-ps-cdn.js | tr -d "\n")
|
|
449
|
+
if [ "${CDN_BANNER}" = "${LOCAL_BANNER}" ]; then
|
|
450
|
+
echo "CDN OK — client bootstrap served from ${CDN_URL}"
|
|
451
|
+
echo " banner: ${CDN_BANNER}"
|
|
452
|
+
exit 0
|
|
453
|
+
else
|
|
454
|
+
echo "Attempt ${i}: HTTP 200 but banner mismatch (likely CDN cache lag)."
|
|
455
|
+
echo " cdn : ${CDN_BANNER}"
|
|
456
|
+
echo " local: ${LOCAL_BANNER}"
|
|
457
|
+
fi
|
|
458
|
+
else
|
|
459
|
+
echo "Attempt ${i}: HTTP ${STATUS} from ${CDN_URL}"
|
|
460
|
+
fi
|
|
461
|
+
|
|
462
|
+
i=$((i + 1))
|
|
463
|
+
if [ "${i}" -le "${CDN_VERIFY_RETRIES}" ]; then
|
|
464
|
+
sleep "${CDN_VERIFY_SLEEP_SEC}"
|
|
465
|
+
fi
|
|
466
|
+
done
|
|
467
|
+
|
|
468
|
+
echo "CDN verification FAILED after ${CDN_VERIFY_RETRIES} attempts."
|
|
469
|
+
exit 1
|
|
470
|
+
'''
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
230
474
|
// ---------------------------------------------------------------------
|
|
231
475
|
stage('Finish') {
|
|
232
476
|
steps {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
477
|
+
script {
|
|
478
|
+
echo "==============================================================="
|
|
479
|
+
echo " Deploy job completed successfully."
|
|
480
|
+
if (params.DEPLOY_SDK) {
|
|
481
|
+
echo " SDK"
|
|
482
|
+
echo " npm package : ${env.NPM_PACKAGE_NAME}@${params.DEPLOY_VERSION}"
|
|
483
|
+
echo " S3 destination : s3://${env.S3_BUCKET}/${env.S3_KEY_PREFIX}/${env.S3_OBJECT_NAME}"
|
|
484
|
+
echo " CDN URL : ${env.CDN_BASE_URL}/${env.CDN_VERIFY_PATH}"
|
|
485
|
+
} else {
|
|
486
|
+
echo " SDK upload skipped (DEPLOY_SDK = false)."
|
|
487
|
+
}
|
|
488
|
+
if (params.DEPLOY_CLIENT_PUBLICIS_PS) {
|
|
489
|
+
echo " Client: publicis/ps"
|
|
490
|
+
echo " Source : ${env.REPO_SRC_DIR}/${env.CLIENT_PS_REL_DIR}"
|
|
491
|
+
echo " S3 destination : s3://${env.S3_BUCKET}/${env.CLIENT_PS_S3_KEY_PREFIX}/${env.CLIENT_PS_BOOTSTRAP_MIN}"
|
|
492
|
+
echo " CDN URL : ${env.CDN_BASE_URL}/${env.CLIENT_PS_CDN_VERIFY_PATH}"
|
|
493
|
+
} else {
|
|
494
|
+
echo " Client publicis/ps upload skipped (DEPLOY_CLIENT_PUBLICIS_PS = false)."
|
|
495
|
+
}
|
|
496
|
+
echo "==============================================================="
|
|
497
|
+
}
|
|
239
498
|
}
|
|
240
499
|
}
|
|
241
500
|
}
|
|
242
501
|
|
|
243
502
|
post {
|
|
244
503
|
success {
|
|
245
|
-
|
|
504
|
+
script {
|
|
505
|
+
def messages = []
|
|
506
|
+
if (params.DEPLOY_SDK) {
|
|
507
|
+
messages << "${env.NPM_PACKAGE_NAME}@${params.DEPLOY_VERSION} -> ${env.CDN_BASE_URL}/${env.CDN_VERIFY_PATH}"
|
|
508
|
+
}
|
|
509
|
+
if (params.DEPLOY_CLIENT_PUBLICIS_PS) {
|
|
510
|
+
messages << "publicis/ps -> ${env.CDN_BASE_URL}/${env.CLIENT_PS_CDN_VERIFY_PATH}"
|
|
511
|
+
}
|
|
512
|
+
echo "SUCCESS: Deployed ${messages.join(' ; ')}"
|
|
513
|
+
}
|
|
246
514
|
}
|
|
247
515
|
failure {
|
|
248
516
|
echo "FAILURE: Deploy job failed at stage '${env.STAGE_NAME}'."
|
|
249
517
|
}
|
|
250
518
|
// Workspace cleanup is intentionally NOT performed in post —
|
|
251
|
-
// the "
|
|
252
|
-
//
|
|
253
|
-
//
|
|
519
|
+
// the "Init Workspace" stage wipes the workspace at the start of
|
|
520
|
+
// every build, and the Workspace Cleanup plugin (cleanWs) is not
|
|
521
|
+
// installed on this Jenkins.
|
|
254
522
|
}
|
|
255
523
|
}
|