Parcourir la source

提交jenkinsfile

林倩 il y a 4 ans
Parent
commit
b0c333b80b
1 fichiers modifiés avec 58 ajouts et 0 suppressions
  1. 58 0
      Jenkinsfile

+ 58 - 0
Jenkinsfile

@@ -0,0 +1,58 @@
+#!groovy
+
+@Library('jenkinslib') _
+
+def color = new org.devops.color()
+def build = new org.devops.build()
+def systemtime = new org.devops.systemtime()
+
+
+pipeline {
+    agent {
+        node {
+            label 'master'
+        }
+    }
+    options {
+        buildDiscarder(logRotator(numToKeepStr: '10'))
+	    disableConcurrentBuilds()
+    }
+    stages {
+        stage('NPM BUILD') {
+            steps {
+                script {
+                    sh """rm -fr dist"""
+                    color.PrintMes('执行npm打包','green')
+                    //标准的打包命令.如有需要添加安装ui组件,请直接在对应位置(一般在node-sass 那加 && npm install 包名)
+                    build.Build('npm','rm -f package-lock.json && npm install && npm install node-sass && npm run build','master')
+                }
+            }
+        }
+    }
+    post {
+        success {
+            wrap([$class: 'BuildUser']) {
+                script {
+                    systime = systemtime.GetSysTime('yyMMdd')
+                    //读取根目录下的package.json,并解析
+                    result = build.GetNpmVersion('package.json')
+                    name = result[0]
+                    version = result[1]
+                    //删除上一次打包时候的tar包
+                    sh """ rm -fr target
+                        mkdir target
+                        tar --exclude-vcs -czvf target/${name}-${version}-${env.GIT_COMMIT.take(8)}-BETA-${systime}.tar.gz dist/ """
+                    archiveArtifacts 'target/*.tar.gz'
+                    currentBuild.description = "Start By ${env.BUILD_USER} And Build Success"
+                }
+            }
+        }
+        failure {
+            wrap([$class: 'BuildUser']) {
+                script {
+                    currentBuild.description = "Start By ${env.BUILD_USER} And Build Failure"
+                }
+            }
+        }
+    }
+}