yazid138 12 hours ago
parent
commit
336d31a01d
1 changed files with 17 additions and 15 deletions
  1. 17 15
      Jenkinsfile

+ 17 - 15
Jenkinsfile

@@ -37,29 +37,31 @@ node {
     }
 	
     stage('Build Deploy '){
-            // // now you are on slave labeled with 'label'
-            // def workspace = WORKSPACE
-            // // ${workspace} will now contain an absolute path to job workspace on slave
-
-            // workspace = env.WORKSPACE
-            // // ${workspace} will still contain an absolute path to job workspace on slave
-
-            // // When using a GString at least later Jenkins versions could only handle the env.WORKSPACE variant:
-            // echo "Current workspace is ${env.WORKSPACE}"
-
-            // // the current Jenkins instances will support the short syntax, too:
-            // echo "Current workspace is $WORKSPACE"
-        docker.withTool("myDocker"){
+      docker.withTool("myDocker"){
             docker.withRegistry(registryAddress, registryCredential) {
 
-				def dockerImage = docker.build("ptb-fe:${env.BUILD_ID}")
+                def dockerImage = docker.build("ptb-fe:${env.BUILD_ID}")
 
                 /* Push the container to the custom Registry */
                 dockerImage.push()
                 dockerImage.push('latest')
+
+                def imageName = "000-dev-sidali.kemdiktisaintek.go.id/ptb-fe:latest"
+                def composeDir = '/workdir/production'
+
+                sh "docker pull ${imageName}"
+
+                sh "docker stop ptb-Frontend"
+                sh "docker rm ptb-Frontend"
+
+                sh """cd ${composeDir} && 
+                      docker-compose stop ptb-fe && 
+                      docker-compose rm -f ptb-fe && 
+                      docker-compose up -d ptb-fe"""
+
+                echo "Deploy completed successfully"
             }
         }
-
      }
   }
   catch (err) {