Browse Source

Update Jenkinsfile

Administrator 4 năm trước cách đây
mục cha
commit
df292607bb
1 tập tin đã thay đổi với 25 bổ sung2 xóa
  1. 25 2
      Jenkinsfile

+ 25 - 2
Jenkinsfile

@@ -3,9 +3,11 @@
 
 def build = new org.devops.build()
 def color = new org.devops.color()
+def systemtime = new org.devops.systemtime()
 
-String cpu = "${env.cpu}"
-String imagePrefix = "${env.imagePrefix}"
+def String cpu = "${env.cpu}"
+def String imagePrefix = "${env.imagePrefix}"
+def String buildImage = "${env.buildImage}"
 
 pipeline {
     agent {
@@ -28,6 +30,7 @@ pipeline {
                 visibleItemCount: 5
         // 需修改对应的镜像名称
         string defaultValue: 'bus.ga/jzywb/dcuc/', description: '请填写打的镜像通用前缀名称,注意最后面要加 / ', name: 'imagePrefix', trim: false
+        choice choices: ['false', 'true'], description: '是否需要打镜像包,默认为否', name: 'buildImage'
     }
     stages {
         stage('MAVEN-BUILD') {
@@ -38,8 +41,28 @@ pipeline {
                     build.Build('mvn', 'mvn clean deploy -DskipTests=true', 'master')
                 }
             }
+            post {
+                success {
+                    script {
+                        version = GetMvnParentVersion()
+                        systime = systemtime.GetSysTime('yyMMdd')
+                        //将打出来的tar包,按照命名规范命名。根据实际情况,修改对应的系统简称和区域标识(DCUC-APP-SERVICE_TJDSJ)
+                        sh """cd dcuc-app-service/target
+                            cp dcuc-app-service-*.tar.gz DCUC-APP-SERVICE_TJDSJ-${version}-${env.GIT_COMMIT.take(8)}-BETA-${systime}.tar.gz
+                        """
+                        //将复制的按照命名规范的tar包提取到Jenkins的面板,方便下载。根据实际情况,修改对应的系统简称和区域标识(DCUC-APP-SERVICE_TJDSJ)
+                        archiveArtifacts artifacts: 'dcuc-app-service/target/DCUC-APP-SERVICE_TJDSJ-*.jar'
+                    }
+                }
+            }
+
         }
         stage('DOCKER-BUILD') {
+            when {
+                expression {
+                    return (buildImage  == 'true')
+                }
+            }
             steps {
                 script {
                     //将cpu架构和模块名称传入方法打镜像包.若在上面定义的参数名称没变,可不修改