|
@@ -8,11 +8,14 @@ pipeline {
|
|
|
|
|
|
environment {
|
|
environment {
|
|
IMAGE_REPO = "SXKJ:32775"
|
|
IMAGE_REPO = "SXKJ:32775"
|
|
|
|
+ IMAGE_REPO_YILI = "registry.cn-hangzhou.aliyuncs.com/sxtest"
|
|
TAB = "\n \n "
|
|
TAB = "\n \n "
|
|
GIT_LOG = sh (script: "git log --oneline -n 1", returnStdout: true).trim()
|
|
GIT_LOG = sh (script: "git log --oneline -n 1", returnStdout: true).trim()
|
|
|
|
+ BUILD_USER_NAME = sh(script: "git log -1 --pretty=format:'%an'", returnStdout: true).trim()
|
|
TITLE = "${JOB_BASE_NAME}-${ENV_APP}"
|
|
TITLE = "${JOB_BASE_NAME}-${ENV_APP}"
|
|
|
|
+ GIT_BRANCH_NAME = env.GIT_BRANCH.substring(env.GIT_BRANCH.lastIndexOf('/') + 1)
|
|
TIMESTAMP = sh(returnStdout: true, script: "TZ=Asia/Shanghai date +'%F_%H-%M-%S'").trim()
|
|
TIMESTAMP = sh(returnStdout: true, script: "TZ=Asia/Shanghai date +'%F_%H-%M-%S'").trim()
|
|
- TAG = "${ENV_APP}-${TIMESTAMP}"
|
|
|
|
|
|
+ TAG = "${ENV_APP}-${GIT_BRANCH_NAME}-${TIMESTAMP}"
|
|
}
|
|
}
|
|
stages {
|
|
stages {
|
|
stage('git-log') {
|
|
stage('git-log') {
|
|
@@ -28,7 +31,13 @@ pipeline {
|
|
steps {
|
|
steps {
|
|
container('docker') {
|
|
container('docker') {
|
|
echo "构建 Docker 镜像阶段"
|
|
echo "构建 Docker 镜像阶段"
|
|
- sh 'docker build -t ${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG} --output type=docker .'
|
|
|
|
|
|
+ sh '''
|
|
|
|
+ if [ "$ENV_APP" == "yiliocr-yn" ]; then
|
|
|
|
+ docker build -t ${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG} --output type=docker .
|
|
|
|
+ else
|
|
|
|
+ xxx
|
|
|
|
+ fi
|
|
|
|
+ '''
|
|
echo "build success"
|
|
echo "build success"
|
|
}
|
|
}
|
|
script {
|
|
script {
|
|
@@ -40,7 +49,13 @@ pipeline {
|
|
steps {
|
|
steps {
|
|
container('docker') {
|
|
container('docker') {
|
|
echo "Push Docker 镜像阶段"
|
|
echo "Push Docker 镜像阶段"
|
|
- sh 'docker push ${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG}'
|
|
|
|
|
|
+ sh '''
|
|
|
|
+ if [ "$ENV_APP" == "yiliocr-yn" ]; then
|
|
|
|
+ docker push ${IMAGE_REPO_YILI}/${JOB_BASE_NAME}:${TAG}
|
|
|
|
+ else
|
|
|
|
+ xxx
|
|
|
|
+ fi
|
|
|
|
+ '''
|
|
echo "Push image success"
|
|
echo "Push image success"
|
|
}
|
|
}
|
|
script {
|
|
script {
|
|
@@ -51,7 +66,13 @@ pipeline {
|
|
stage('重启服务') {
|
|
stage('重启服务') {
|
|
steps {
|
|
steps {
|
|
container('kubectl') {
|
|
container('kubectl') {
|
|
- sh '[[ "$ENV_APP" == "test" ]] && kubectl set image deployment/ocr-table table=${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG} --namespace yili-ocr --kubeconfig kubeconfig-sxkj || kubectl set image deployment/ocr-table table=${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG} --namespace yili-ocr --kubeconfig kubeconfig-sxkjprod'
|
|
|
|
|
|
+ sh '''
|
|
|
|
+ if [ "$ENV_APP" == "yiliocr-yn" ]; then
|
|
|
|
+ echo "$ENV_APP"
|
|
|
|
+ else
|
|
|
|
+ xxx
|
|
|
|
+ fi
|
|
|
|
+ '''
|
|
}
|
|
}
|
|
script {
|
|
script {
|
|
env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
|
|
env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
|
|
@@ -70,7 +91,7 @@ pipeline {
|
|
"msgtype": "markdown",
|
|
"msgtype": "markdown",
|
|
"markdown": {
|
|
"markdown": {
|
|
"title":"${TITLE}",
|
|
"title":"${TITLE}",
|
|
- "text": "😄👍 构建成功 👍😄 \n**项目名称**:${TITLE} \n**Git log**: ${GIT_LOG} \n**构建分支**: ${GIT_BRANCH} \n**构建地址**:${BUILD_URL} \n**构建任务**: ${BUILD_TASKS}"
|
|
|
|
|
|
+ "text": "😄👍 构建成功 👍😄 \n**项目名称**:${TITLE} \n**Git log**: ${GIT_LOG} \n**构建者**: ${BUILD_USER_NAME} \n**构建分支**: ${GIT_BRANCH} \n**构建地址**:${BUILD_URL} \n**构建任务**: ${BUILD_TASKS}"
|
|
}
|
|
}
|
|
}'
|
|
}'
|
|
"""
|
|
"""
|
|
@@ -84,7 +105,7 @@ pipeline {
|
|
"msgtype": "markdown",
|
|
"msgtype": "markdown",
|
|
"markdown": {
|
|
"markdown": {
|
|
"title":"${TITLE}",
|
|
"title":"${TITLE}",
|
|
- "text": "😖❌ 构建失败 ❌😖 \n**项目名称**:${TITLE} \n**Git log**: ${GIT_LOG} \n**构建分支**: ${GIT_BRANCH} \n**构建地址**:${BUILD_URL} \n**构建任务**: ${BUILD_TASKS}"
|
|
|
|
|
|
+ "text": "😖❌ 构建失败 ❌😖 \n**项目名称**:${TITLE} \n**Git log**: ${GIT_LOG} \n**构建者**: ${BUILD_USER_NAME} \n**构建分支**: ${GIT_BRANCH} \n**构建地址**:${BUILD_URL} \n**构建任务**: ${BUILD_TASKS}"
|
|
}
|
|
}
|
|
}'
|
|
}'
|
|
"""
|
|
"""
|