Browse Source

fix jenkinsfile

FabioFratini 10 months ago
parent
commit
701a2d3c04
1 changed files with 6 additions and 9 deletions
  1. 6 9
      Jenkinsfile

+ 6 - 9
Jenkinsfile

@@ -42,8 +42,7 @@ pipeline {
         }
         }
         stage('Setup') {
         stage('Setup') {
             steps {
             steps {
-                // Check versions if available
-                sh '/usr/bin/php --version || echo "PHP not available"'
+                sh 'php --version || echo "PHP not available"'
                 sh 'composer --version || echo "Composer not available"'
                 sh 'composer --version || echo "Composer not available"'
                 sh 'node --version || echo "Node not available"'
                 sh 'node --version || echo "Node not available"'
                 sh 'npm --version || echo "NPM not available"'
                 sh 'npm --version || echo "NPM not available"'
@@ -64,9 +63,9 @@ pipeline {
 
 
         stage('Setup Environment') {
         stage('Setup Environment') {
             steps {
             steps {
-                sh '/usr/bin/php artisan key:generate || echo "Skipping key generation"'
-                sh '/usr/bin/php artisan config:clear || echo "Skipping config clear"'
-                sh '/usr/bin/php artisan cache:clear || echo "Skipping cache clear"'
+                sh 'php artisan key:generate || echo "Skipping key generation"'
+                sh 'php artisan config:clear || echo "Skipping config clear"'
+                sh 'php artisan cache:clear || echo "Skipping cache clear"'
             }
             }
         }
         }
 
 
@@ -86,8 +85,8 @@ pipeline {
 
 
         stage('Deploy to Server') {
         stage('Deploy to Server') {
             when {
             when {
-                anyOf {
-                    branch 'develop'
+                expression {
+                    return env.BRANCH_NAME == 'develop'
                 }
                 }
             }
             }
             steps {
             steps {
@@ -113,11 +112,9 @@ pipeline {
                         chown -R www-data:www-data .'
                         chown -R www-data:www-data .'
                     """
                     """
 
 
-                    // Restart relevant services if needed
                     sh "ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'sudo systemctl restart php8.1-fpm || sudo systemctl restart php-fpm || echo \"PHP service restart failed, may need manual intervention\"'"
                     sh "ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'sudo systemctl restart php8.1-fpm || sudo systemctl restart php-fpm || echo \"PHP service restart failed, may need manual intervention\"'"
                     sh "ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'sudo systemctl restart nginx || echo \"Nginx restart failed, may need manual intervention\"'"
                     sh "ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'sudo systemctl restart nginx || echo \"Nginx restart failed, may need manual intervention\"'"
 
 
-                    // Clear any caches
                     sh "ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'cd ${REMOTE_DIR} && php artisan cache:clear'"
                     sh "ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'cd ${REMOTE_DIR} && php artisan cache:clear'"
                 }
                 }
             }
             }