Explorar el Código

build: 增加打jar包配置

huangzqa hace 4 años
padre
commit
f430b7c54b
Se han modificado 1 ficheros con 25 adiciones y 2 borrados
  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}"
+String buildImage = "${env.buildImage}"
 
 pipeline {
     agent {
@@ -20,14 +22,15 @@ pipeline {
 
     //设定2个参数,根据项目类型不同,修改对应的description name value visibleItemCount  defaultValue 即可
     parameters {
-        extendedChoice description: '请选择CPU架构.可单选/多选/全选', multiSelectDelimiter: ',', name: 'cpu',
+        choice choices: ['false', 'true'], description: '是否需要打镜像包,默认为否', name: 'buildImage'
+        extendedChoice description: '只有在需要打镜像包的情况下,才需要选择CPU架构。可单选/多选/全选', multiSelectDelimiter: ',', name: 'cpu',
                 quoteValue: true,
                 saveJSONParameterToFile: false,
                 type: 'PT_CHECKBOX',
                 value: 'x86,arm64',
                 visibleItemCount: 5
         // 需修改对应的镜像名称
-        string defaultValue: 'bus.ga/jzywb/dcuc/', description: '请填写打的镜像通用前缀名称,注意最后面要加 / ', name: 'imagePrefix', trim: false
+        string defaultValue: 'bus.ga/jzywb/dcuc/', description: '只有在需要打镜像包的情况下,才需要填写要打镜像通用前缀名称,注意最后面要加 / ', name: 'imagePrefix', trim: false
     }
     stages {
         stage('MAVEN-BUILD') {
@@ -38,8 +41,28 @@ pipeline {
                     build.Build('mvn', 'mvn clean deploy -DskipTests=true', 'master')
                 }
             }
+            post {
+                success {
+                    script {
+                        version = build.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-*.tar.gz'
+                    }
+                }
+            }
+
         }
         stage('DOCKER-BUILD') {
+            when {
+                expression {
+                    return (buildImage  == 'true')
+                }
+            }
             steps {
                 script {
                     //将cpu架构和模块名称传入方法打镜像包.若在上面定义的参数名称没变,可不修改