wuheng 2 lat temu
rodzic
commit
165302a26a
1 zmienionych plików z 6 dodań i 5 usunięć
  1. 6 5
      Jenkinsfile

+ 6 - 5
Jenkinsfile

@@ -1,16 +1,21 @@
 pipeline {
     agent any
+    environment {
+        BRANCH_NAME="${env.BRANCH_NAME}".toLowerCase()
+    }
     stages {
         stage('Build') {
             agent {
                 docker {
-                    image 'node:16-alpine'  
+                    image 'node:16-alpine'
+                    args '-v /var/run/docker.sock:/var/run/docker.sock -v /usr/local/bin/docker-compose:/usr/local/bin/docker-compose'  
                 }
             }
             steps {
                 sh 'docker-compose down'
                 sh 'npm install --registry https://registry.npm.taobao.org'
                 sh 'npm run build:prod'
+                sh 'docker build -t ${BRANCH_NAME}:${BUILD_NUMBER} .'
             }
         }
         stage('Test') {
@@ -19,12 +24,8 @@ pipeline {
             }
         }
         stage('Deploy') {
-            environment {
-                BRANCH_NAME="${env.BRANCH_NAME}".toLowerCase()
-            }
             steps {
                 echo 'Deploying....'
-                sh 'docker build -t ${BRANCH_NAME}:${BUILD_NUMBER} .'
                 sh 'docker-compose up -d'
             }
         }