From 28c1ab284940a36a73e619dd7d749b143fed96fa Mon Sep 17 00:00:00 2001
From: william <william.vonhagen@gmail.com>
Date: Tue, 10 Jun 2025 01:19:42 +0000
Subject: [PATCH] Update 'Jenkinsfile'

---
 Jenkinsfile | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 5044df4..4d4fed0 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,14 +1,21 @@
 pipeline {
     agent any
     stages {
-        stage('Checkout') {
+        stage("Checkout and build react app") {
+            when { expression { true }  }
             steps {
-                git 'http://git.abilityell.com/william/react-project.git'
-            }
-        }
-        stage('Build') {
-            steps {
-                sh 'mvn clean package'
+                git(url: 'http://git.abilityell.com/william/react-project.git', branch: 'main')
+                
+                withEnv(['CI=false']) {     //ignore warning
+                    sh 'npm install'
+                    sh 'npm run build'
+                }    
+                
+                sh '''
+                    echo "build react ..."
+                    pwd 
+                    ls -l build 
+                '''
             }
         }
         stage('Test') {
@@ -16,11 +23,18 @@ pipeline {
                 sh 'mvn test'
             }
         }
-        stage('Deploy') {
+        stage("Deploy React App") {
+            when { expression { false }  }
             steps {
-                sh 'kubectl apply -f deployment.yaml'
+                withCredentials([sshUserPrivateKey(credentialsId: 'docker-ssh', keyFileVariable: 'SSH_KEY')]) {
+                    sh '''
+                        scp -i $SSH_KEY -o StrictHostKeyChecking=no -r build/* $DOCKER_HOST:/var/www/html/
+                        
+                        ssh -i $SSH_KEY -o StrictHostKeyChecking=no $DOCKER_HOST 'chmod -R 755 /var/www/html/*'
+                    '''
+                }
             }
-        }
+        }    
     }
     post {
         success {
@@ -30,4 +44,4 @@ pipeline {
             echo "Pipeline failed! ❌"
         }
     }
-}
\ No newline at end of file
+}