加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Jenkinsfile.groovy 3.13 KB
一键复制 编辑 原始数据 按行查看 历史
alikes 提交于 2022-04-08 20:47 . 日志配置
/** ========================= 标准配置 ============================= **/
import com.trax.devops.publish.*
import hudson.model.*
@Library('trax-cicd-lib') _
//发布的镜像
def imageMap = [:]
def group = 'dockerimg.lenztechretail.com'
def nameSpace = 'tope'
//maven版本,用来构建的脚本,确定 snapshot / release
def mavenVersion = "release"
//版本号
String tag = "${BUILD_TAG}"
//环境列表
def deployEnvList = ['dev']
/** ========================= 应用自定义 ============================= **/
//应用前缀
def appPrefix = "xxl"
//项目名
def projectName = "${appPrefix}-job"
//服务所在目录,会根据该目录结合appName寻找jar包进行docker镜像构建
def serviceDir = "."
//发布的应用
def appNames = ["job-manager"]
//git仓库地址
def gitUrl = "git@gitee.com:ppz_bj/${projectName}.git"
//通知版本号的dataID
def nacosDataId = "${projectName}.yml"
/** ========================= 发布环境(仅包含发布时使用) ============================= **/
pipeline {
agent any
stages {
stage('Git Checkout') {
steps {
script {
echo "Checkout...${BRANCH_NAME}"
checkout scm
}
}
}
stage('Branch Check') {
steps {
script {
checkTag(BRANCH_NAME)
}
}
}
stage('Input Env') {
steps {
timeout(time: 1, unit: 'MINUTES') {
script {
env.DEPLOY_ENV = input message: '选择部署的环境', ok: 'deploy',
parameters: [choice(name: 'DEPLOY_ENV', choices: ['dev', 'test', 'uat' ,'prod'], description: '选择部署环境')]
println("build ${env.DEPLOY_ENV} env")
deployEnvList = ["${env.DEPLOY_ENV}"]
}
}
}
}
stage('Maven Build') {
steps {
script {
if (deployEnvList == ['prod'] && "${BRANCH_NAME}".startsWith("master")){
mavenVersion = "release"
}else{
mavenVersion = "snapshot"
}
maven(mavenVersion)
}
}
}
stage('Build and Push Image') {
steps {
script {
customDocker.build(group, nameSpace, tag, serviceDir, appNames, imageMap)
}
}
}
stage("Publish Version") {
steps {
script {
PublishImage.noticeNacos(nacosDataId, imageMap, deployEnvList)
Notice.noticeK8sNacos(nacosDataId, imageMap, deployEnvList)
}
}
}
stage('GIT ARCHIVING') {
steps {
script {
if (deployEnvList == ['prod'] && "${BRANCH_NAME}".startsWith("master")) {
customGit.tag(gitUrl)
}
}
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化