1 Star 0 Fork 47

kylinjone/vue3-composition-admin

forked from ZY/vue3-composition-admin 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Jenkinsfile 4.40 KB
一键复制 编辑 原始数据 按行查看 历史
李聚章 提交于 2021-01-25 14:21 . 添加部署文件
@Library('devops') _
pipeline {
agent {label 'jenkins-slave-jnlp'}
environment { // https://stackoverflow.com/questions/53541489/updating-environment-global-variable-in-jenkins-pipeline-from-the-stage-level
NAME="admin-tmpl"
NAMESPACE="oppc-rcyj-web"
SERVER_PORT="80"
}
options {
// timestamps() //日志会有时间
skipDefaultCheckout() //删除隐式checkout scm语句
// disableConcurrentBuilds() //禁止并行,会列队式等前面的任务完才进行下一个任务
timeout(time: 1, unit: 'HOURS') //流水线超时设置1h
}
stages {
stage('Init'){
steps {
script{
// 【测试环境】变量
env.INGRESS_HOST='admin-tmpl-test.rencaiyoujia.cn'
env.INGRESS_TLS_SECRET="rencaiyoujia-tls-secret"
env.REPLICAS="1" //deployment的副本数
KUBECONTEXT = "k8s-test-admin" //测试环境k8s
NPM_RUN_BUILD_CMD="npm run build:test"
DOCKERFILE_NAME="Dockerfile"
// 【生产环境】变量
if( "${BRANCH_NAME}"== "master"){
env.INGRESS_HOST='admin-tmpl.rencaiyoujia.com'
env.INGRESS_TLS_SECRET="rencaiyoujia-tls-secret"
env.REPLICAS="2"
KUBECONTEXT="k8s-prod-admin" //生产环境k8s
NPM_RUN_BUILD_CMD="npm run build:prod"
DOCKERFILE_NAME="Dockerfile"
}
// 【开发环境】变量
if( "${BRANCH_NAME}"== "dev"){
env.INGRESS_HOST='admin-tmpl-dev.rencaiyoujia.cn'
env.INGRESS_TLS_SECRET="rencaiyoujia-tls-secret"
env.REPLICAS="1"
KUBECONTEXT="k8s-dev-admin" //开发环境k8s
NPM_RUN_BUILD_CMD="npm run build:dev"
DOCKERFILE_NAME="Dockerfile"
}
}
}
}
stage('Checkout') {
steps {
checkout scm
}
}
stage('npm打包') {
steps {
script{
// sh 'npm config set registry https://registry.npm.taobao.org'
sh 'npm install --registry=https://registry.npm.taobao.org'
sh "${NPM_RUN_BUILD_CMD}"
}
}
}
stage('DockerBuild') {
steps {
script{
sh "rm -rf docker/dist;mv dist docker"
devops.docker(env.NAME,dockerfile:"docker/${DOCKERFILE_NAME}",context:"docker").build().push()
}
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
stage('Deploy') {
parallel {
stage('deploy ingress') {
when {
expression { env.INGRESS_HOST != null }
}
steps{
sh """envsubst < k8smanifests/svc.yaml | kubectl --context ${KUBECONTEXT} apply -f - ;\
envsubst < k8smanifests/ingress.yaml | kubectl --context ${KUBECONTEXT} apply -f - ;\
"""
}
}
stage('Deploy') {
steps{
sh """envsubst < k8smanifests/deploy.yaml ;\
envsubst < k8smanifests/deploy.yaml | kubectl --context ${KUBECONTEXT} apply -f - ;\
"""
}
}
}
}
}
post{
success{
script{
devops.dingtalk(env.NAME,env.DOCKERIMAGE,"构建成功 ✅")
}
}
failure{
script{
devops.dingtalk(env.NAME,env.DOCKERIMAGE,"构建失败 ❌")
}
}
unstable{
script{
devops.dingtalk(env.NAME,env.DOCKERIMAGE,"不稳定构建 ✅")
}
}
aborted{
script{
devops.dingtalk(env.NAME,env.DOCKERIMAGE,"暂停或中断 ❌")
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kylinjone/vue3-composition-admin.git
git@gitee.com:kylinjone/vue3-composition-admin.git
kylinjone
vue3-composition-admin
vue3-composition-admin
main

搜索帮助