blob: a4809d4ef95cfebe9567ebf8e063e68707db1ad2 (
plain)
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
|
pipeline {
agent any
triggers {
cron('H */6 * * *')
pollSCM('H/1 * * * *')
}
environment {
BUILD_DIR = 'dist'
SENTRY_AUTH_TOKEN = credentials('2b685078-e5d8-49a7-af60-b8ec44bc2734')
}
options {
skipDefaultCheckout()
}
stages {
stage('setup') {
steps {
cleanWs()
checkout scmGit(
branches: [[name: env.BRANCH_NAME]],
extensions: [ cloneOption(shallow: true) ],
userRemoteConfigs: [
[credentialsId: 'abdeb570-b708-44f3-b857-8a6b06ed9822',
url: 'ssh://code.g-r-l.com:6611/panels/amt-jb']
],
)
}
}
stage('env') {
steps {
withCredentials([file(
credentialsId: 'amt-jb-ui-env',
variable: 'ENV_FILE_PATH')]) {
sh "cp \$ENV_FILE_PATH ${WORKSPACE}/jb-ui/.env.production"
}
}
}
stage('pnpm.install') {
steps {
dir('jb-ui') {
sh 'pnpm install'
}
}
}
stage('pnpm.test') {
steps {
dir('jb-ui') {
sh 'pnpm run test'
}
}
}
stage('pnpm.build') {
steps {
dir('jb-ui') {
sh 'pnpm run build'
script {
def props = readJSON file: 'dist/.vite/manifest.json'
def jsFile = props["src/main.tsx"]["file"]
dir(env.BUILD_DIR) {
def minSize = 750 * 1024
def size = sh(script: "stat -c%s ${jsFile}", returnStdout: true).trim().toInteger()
if (size < minSize) {
error "Build is too small: ${size} bytes"
} else {
echo "Build size is acceptable: ${size} bytes"
}
}
}
}
}
}
stage('cdn.deploy') {
steps {
sh "/usr/bin/rsync -avz ${WORKSPACE}/jb-ui/${env.BUILD_DIR}/ cdn-jb:/var/www/amt-jb-cdn/"
// This already gets moved over in a hidden folder, but let's
// make it more clear because dev builds would overwrite it
sh "/usr/bin/rsync -avz ${WORKSPACE}/jb-ui/${env.BUILD_DIR}/.vite/manifest.json cdn-jb:/var/www/amt-jb-cdn/manifest-${env.BRANCH_NAME}.json"
}
}
stage('cdn.deploy.tag') {
when {
expression {
return env.TAG_NAME?.trim()
}
}
steps {
sh "/usr/bin/rsync -avz ${WORKSPACE}/jb-ui/${env.BUILD_DIR}/ cdn-jb:/var/www/amt-jb-cdn/"
// This already gets moved over in a hidden folder, but let's
// make it more clear because dev builds would overwrite it
sh "/usr/bin/rsync -avz ${WORKSPACE}/jb-ui/${env.BUILD_DIR}/.vite/manifest.json cdn-jb:/var/www/amt-jb-cdn/manifest-${env.BRANCH_NAME}-${env.TAG_NAME}.json"
}
}
}
}
|