Selaa lähdekoodia

Jenkinsfile configuracion para dev y test

Francisco huezo 5 vuotta sitten
vanhempi
commit
2cc20c89a4
1 muutettua tiedostoa jossa 30 lisäystä ja 9 poistoa
  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'
+                                '''
+                        }
+                    }
+                }                
             }
         }
     }