jenkinsfile 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. pipeline {
  2. agent any
  3. tools {
  4. nodejs "NodeJS24.7.0" // Name same as in Global Tool Config
  5. }
  6. triggers {
  7. // poll SCM every 2 minutes
  8. pollSCM('* * * * *')
  9. }
  10. stages {
  11. stage('Checkout') {
  12. steps {
  13. echo "📥 Pulling code from Gogs..."
  14. git branch: 'master',
  15. url: 'https://scm.finlabsindia.org/samruddhi/Test_Repo_React_Project.git',
  16. credentialsId: 'gogs-pat-for-react-app' // Jenkins credential ID for PAT
  17. }
  18. }
  19. stage('Install Dependencies') {
  20. steps {
  21. echo "📦 Installing dependencies..."
  22. sh 'npm install'
  23. }
  24. }
  25. stage('Build') {
  26. steps {
  27. echo "🏗️ Building React app..."
  28. sh 'npm run build'
  29. }
  30. }
  31. stage('Deploy') {
  32. steps {
  33. echo "🚀 Deploying React app..."
  34. // Dummy command for testing
  35. sh 'echo "Simulating deploy step: copying build/ to web server path"'
  36. // 🔥 Real deploy example:
  37. // sh 'cp -r build/* /var/www/html/'
  38. }
  39. }
  40. }
  41. post {
  42. always {
  43. echo "🧹 Cleaning workspace..."
  44. cleanWs()
  45. }
  46. }
  47. }