12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #!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"
- }
- }
- }
- }
- }
|