代码拉取完成,页面将自动刷新
pipeline {
agent any
environment {
USER_EMAIL = "shunshun.liu@baozun.com" //发送邮件的地址(一般为项目owner,按实际修改)
USER = "shunshun.liu" //发送邮件的邮箱前缀(一般为项目owner,按实际修改)
PROJECT_NAME = "oms4" //项目名,按实际修改
APP_NAME = "push-socket push-logic" //应用名,按实际修改,如有多个,在括号内添加,以空格间隔(例如"ofa-service-a ofa-service-b ofa-service-c")
HARBOR_ADDR = "ic-harbor.baozun.com" //Harbor地址,无需修改
DOCKER_NAME = "Dockerfile" //Dockerfile文件位置,如有多个,在括号内添加,以空格间隔,顺序按照APP_NAME一样(例如"ecs-ofa-service-impl-a/docker/Dockerfile-ecs ecs-ofa-service-impl-a/docker/Dockerfile-ecs ecs-ofa-service-impl-c/docker/Dockerfile-ecs")
}
options {
buildDiscarder(logRotator(numToKeepStr: '5', artifactNumToKeepStr: '5')) //保留历史记录,无需修改
}
//pipeline运行结果通知给触发者,无需修改
post {
failure {
script {
wrap([$class: 'BuildUser']) {
emailext body: '$DEFAULT_CONTENT', recipientProviders: [developers()], mimeType: 'text/html', subject: '$DEFAULT_SUBJECT', to: "$USER_EMAIL"
}
}
}
unstable {
script {
wrap([$class: 'BuildUser']) {
emailext body: '$DEFAULT_CONTENT', recipientProviders: [developers()], mimeType: 'text/html', subject: '$DEFAULT_SUBJECT', to: "$USER_EMAIL"
}
}
}
aborted {
script {
wrap([$class: 'BuildUser']) {
emailext body: '$DEFAULT_CONTENT', recipientProviders: [developers()], mimeType: 'text/html', subject: '$DEFAULT_SUBJECT', to: "$USER_EMAIL"
}
}
}
}
stages {
stage('打包&上传镜像') {
when { anyOf{ branch 'release';branch 'master';branch 'develop'} }
steps {
timeout(time: 20, unit: 'MINUTES') {
sh '''
if [[ "$BRANCH_NAME" =~ release ]];then
envname="uat"
elif [[ "$BRANCH_NAME" =~ master ]];then
envname="prod"
elif [[ "$BRANCH_NAME" =~ dev ]];then
envname="sit"
fi
for app in $APP_NAME;do
docker images --filter="reference=${HARBOR_ADDR}/${envname}/${PROJECT_NAME}_${app}:*" -q | xargs --no-run-if-empty docker rmi --force
docker build --no-cache -t ${HARBOR_ADDR}/${envname}/${PROJECT_NAME}_${app}:${GIT_COMMIT:0:7} -f ${DOCKER_NAME} ./
docker push ${HARBOR_ADDR}/${envname}/${PROJECT_NAME}_${app}:${GIT_COMMIT:0:7}
done
'''
}
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。