Преглед на файлове

Merge branch 'feature-CI_CD' of onunez/frontend-inversiones into development

Jenkinsfile configuracion para dev y test
Francisco Huezo преди 5 години
родител
ревизия
69ce1186a3
променени са 1 файла, в които са добавени 30 реда и са изтрити 9 реда
  1. 30 9
      Jenkinsfile

+ 30 - 9
Jenkinsfile

@@ -3,10 +3,21 @@ pipeline {
     stages {
         stage('build') {
             steps {
-                sh  '''
-                    cd /opt/inversys/app/frontend/
-                    git pull
-                    '''
+                script {
+                    if(env.JOB_NAME == 'DEV_inversys_frontend'){
+                        sh  '''
+                            cd /opt/inversys/app/frontend/
+                            git pull
+                            '''
+                    }
+                    else if(env.JOB_NAME == 'TST_inversys_frontend'){
+                        sshagent(credentials: ['deployment-key']) {
+                            sh  '''
+                                ssh deploy@192.168.98.48 'cd /opt/inversys/app/frontend/ && git pull'
+                                '''
+                        }
+                    }
+                }                
             }
         }
         stage('Test') {
@@ -16,11 +27,21 @@ pipeline {
         }
         stage('Deploy') {
             steps {
-                sh  '''
-                    cd /opt/inversys/
-                    echo $USER
-                    docker-compose up -d --build frontend
-                    '''
+                script {
+                    if(env.JOB_NAME == 'DEV_inversys_frontend'){
+                        sh  '''
+                            cd /opt/inversys/
+                            docker-compose up -d --build frontend
+                            '''
+                    }
+                    else if(env.JOB_NAME == 'TST_inversys_frontend'){
+                        sshagent(credentials: ['deployment-key']) {
+                            sh  '''
+                                ssh deploy@192.168.98.48 'cd /opt/inversys/ && docker-compose up -d --build frontend'
+                                '''
+                        }
+                    }
+                }                
             }
         }
     }