Browse Source

commited jenkinsfile

samruddhi lehekar 3 months ago
parent
commit
0c46549bca
1 changed files with 56 additions and 0 deletions
  1. 56 0
      jenkinsfile

+ 56 - 0
jenkinsfile

@@ -0,0 +1,56 @@
+pipeline {
+    agent any
+
+    tools {
+        nodejs "NodeJS24.7.0"   // Name same as in Global Tool Config
+    }
+
+    triggers {
+        // poll SCM every 2 minutes
+        pollSCM('H/2 * * * *')
+    }
+
+    stages {
+        stage('Checkout') {
+            steps {
+                echo "📥 Pulling code from Gogs..."
+                git branch: 'master',
+                    url: 'https://scm.finlabsindia.org/samruddhi/Test_Repo_React_Project.git',
+                    credentialsId: 'gogs-pat-for-react-app'  // Jenkins credential ID for PAT
+            }
+        }
+
+        stage('Install Dependencies') {
+            steps {
+                echo "📦 Installing dependencies..."
+                sh 'npm install'
+            }
+        }
+
+        stage('Build') {
+            steps {
+                echo "🏗️ Building React app..."
+                sh 'npm run build'
+            }
+        }
+
+        stage('Deploy') {
+            steps {
+                echo "🚀 Deploying React app..."
+                // Dummy command for testing
+                sh 'echo "Simulating deploy step: copying build/ to web server path"'
+
+                // 🔥 Real deploy example:
+                // sh 'cp -r build/* /var/www/html/'
+            }
+        }
+    }
+
+    post {
+        always {
+            echo "🧹 Cleaning workspace..."
+            cleanWs()
+        }
+    }
+}
+