summaryrefslogtreecommitdiff
path: root/jb-ui/Jenkinsfile
diff options
context:
space:
mode:
authorMax Nanis2026-02-18 20:42:03 -0500
committerMax Nanis2026-02-18 20:42:03 -0500
commit3eaa56f0306ead818f64c3d99fc6d230d9b970a4 (patch)
tree9fecc2f1456e6321572e0e65f57106916df173e2 /jb-ui/Jenkinsfile
downloadamt-jb-3eaa56f0306ead818f64c3d99fc6d230d9b970a4.tar.gz
amt-jb-3eaa56f0306ead818f64c3d99fc6d230d9b970a4.zip
HERE WE GO, HERE WE GO, HERE WE GO
Diffstat (limited to 'jb-ui/Jenkinsfile')
-rw-r--r--jb-ui/Jenkinsfile140
1 files changed, 140 insertions, 0 deletions
diff --git a/jb-ui/Jenkinsfile b/jb-ui/Jenkinsfile
new file mode 100644
index 0000000..2735dc6
--- /dev/null
+++ b/jb-ui/Jenkinsfile
@@ -0,0 +1,140 @@
+pipeline {
+ agent any
+
+ triggers {
+ cron('H */6 * * *')
+ pollSCM('H/1 * * * *')
+ }
+
+ environment {
+ BUILD_DIR = "dist"
+ JS_FILENAME = "james-billings"
+ CSS_FILENAME = "james-has-style"
+ }
+
+ 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 {
+ dir(env.BUILD_DIR) {
+ def minSize = 750 * 1024
+ def size = sh(script: "stat -c%s ${env.JS_FILENAME}.js", 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.master') {
+ when {
+ expression { env.BRANCH_NAME == 'master' }
+ }
+ steps {
+ sh "/usr/bin/rsync -avz ${WORKSPACE}/jb-ui/${env.BUILD_DIR}/ thl-cdn:/root/amt-jb-cdn/"
+ }
+ }
+
+ stage('cdn.deploy.non-master') {
+ when {
+ expression { env.BRANCH_NAME != 'master' }
+ }
+ steps {
+ dir("jb-ui") {
+ script {
+ echo "Detected branch: ${env.BRANCH_NAME}"
+ def versioned_js = "${env.JS_FILENAME}-${env.BRANCH_NAME}"
+ def versioned_css = "${env.CSS_FILENAME}-${env.BRANCH_NAME}"
+
+ dir(env.BUILD_DIR) {
+ sh "cp ${env.JS_FILENAME}.js ${versioned_js}.js"
+ sh "cp ${env.CSS_FILENAME}.js ${versioned_css}.js"
+
+ sh "/usr/bin/rsync -avz ${WORKSPACE}/jb-ui/${env.BUILD_DIR}/ thl-cdn:/root/amt-jb-cdn/"
+ }
+ }
+
+ }
+ }
+ }
+
+ stage('cdn.deploy.tag') {
+ when {
+ expression {
+ return env.TAG_NAME?.trim()
+ }
+ }
+
+ steps {
+ dir("jb-ui") {
+ script {
+ echo "Detected tag: ${env.TAG_NAME}"
+ def versioned_js = "${env.JS_FILENAME}-${env.TAG_NAME}"
+ def versioned_css = "${env.CSS_FILENAME}-${env.TAG_NAME}"
+
+ dir(env.BUILD_DIR) {
+ sh "cp ${env.JS_FILENAME}.js ${versioned}.js"
+ sh "cp ${env.CSS_FILENAME}.js ${versioned}.js"
+
+ sh "/usr/bin/rsync -avz ${WORKSPACE}/jb-ui/${env.BUILD_DIR}/ thl-cdn:/root/amt-jb-cdn/"
+ }
+ }
+
+ }
+ }
+ }
+ }
+}