pipeline {
|
agent any
|
// nodejs 安装
|
// agent {
|
// docker {
|
// image 'node:12.20.1-alpine3.11'
|
// }
|
// }
|
//变量定义
|
environment {
|
REGISTRY = 'registry.cn-hangzhou.aliyuncs.com'
|
DOCKERHUB_NAMESPACE = 'arsn'
|
}
|
|
stages {
|
//1.拉取源码
|
stage('Git Checkout'){
|
steps {
|
git branch: 'master', credentialsId: 'gitblit', url: 'http://192.168.0.105:10010/r/zhba_enterprises.git'
|
}
|
}
|
//2.编译成jar包
|
stage('Maven Build') {
|
steps {
|
sh 'ls'
|
sh 'node --version'
|
sh 'npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/'
|
sh 'npm install'
|
sh 'npm run build'
|
}
|
}
|
|
|
stage('copy dist to nginx') {
|
steps {
|
sh 'ls'
|
sh 'exit'
|
sh 'ls'
|
sh 'docker cp jenkins:/var/jenkins_home/workspace/zhbaw-vue/dist/ /home/nginx'
|
}
|
}
|
//3.构建镜像并上传到阿里云镜像仓库
|
// stage('Build and Push Image'){
|
// steps{
|
// sh 'docker build -t zhba-vue:latest -f Dockerfile .'
|
// }
|
// }
|
// //4.拉取镜像并启动
|
// stage('Pull Image and Run'){
|
// steps{
|
// script{
|
// withCredentials([usernamePassword(credentialsId: 'aliyun', passwordVariable: 'password', usernameVariable: 'username')]) {
|
// sh 'echo "$password" | docker login $REGISTRY -u "$username" --password-stdin'
|
// sh 'docker tag zhba-vue:latest $REGISTRY/$DOCKERHUB_NAMESPACE/zhba-vue:SNAPSHOT-$BUILD_NUMBER'
|
// sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/zhba-vue:SNAPSHOT-$BUILD_NUMBER'
|
// }
|
// }
|
// }
|
// }
|
//部署
|
// stage('deploy to dev') {
|
// steps {
|
// input '是否部署?'
|
// // sh 'docker-compose up -d'
|
// sh 'docker run zhba-vue:latest'
|
// }
|
// }
|
}
|
}
|