Jenkins 安装 (七) 前端流水线

创建

备注描述内容

构建触发器 (默认)

高级项目选项 (默认)

流水线 (重点)

pipeline {
    agent any

    stages {
      stage('Pull Source code') {
        steps {
          script{
            git branch: 'develop', credentialsId: '6d704e40-401f-4f70-9724-0f8fc2ab8be6', url: 'https://gitlab.51qqt.com/qqtmall/mallmanager.git'
		}
      }
	}
      stage('Build Project') {
        steps {
             	sh '''
                    npm install
                    npm run build
              '''
          }
      }
        stage('zip dist') {
          steps {
             	      sh '''cd /mnt/soft/tomact/.jenkins/workspace/Develop_PC_Web/static
rm -rf dist.tar.gz
tar -zcvf dist.tar.gz *'''
          }
      }
  
      stage('ssh push dist') {
        steps {
		sshPublisher(publishers: [sshPublisherDesc(configName: 'Tomcat02', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '''cd /mnt/soft/malls/pc_web
rm -r dist
tar -zxvf dist.tar.gz
rm -r dist.tar.gz
''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: 'malls/pc_web', remoteDirectorySDF: false, removePrefix: 'static/', sourceFiles: 'static/dist.tar.gz')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
		}
      }
    stage('Clear cache') {
        steps {
          script{
				sh '''cd /mnt/soft/tomact/.jenkins/workspace/Develop_PC_Web
rm -rf static'''
		  }
        }
      }
	 }
}

上一篇 Jenkins 安装 (六) 后端流水线
目录