xlcs/xlcs-parent/service-gateway/Jenkinsfile

59 lines
1.5 KiB
Plaintext
Raw Normal View History

pipeline {
environment {
DOCKER_REGISTRY = "10.211.55.2:8083"
DOCKER_IMAGE_NAME = "service-gateway"
DOCKER_IMAGE_TAG = "${env.DATETIME}"
DOCKER_LOGIN_USERNAME = "admin"
DOCKER_LOGIN_PASSWORD = "adminadmin"
}
agent {
kubernetes {
inheritFrom 'maven'
containerTemplate {
name 'maven'
image 'maven:3.8.4-jdk-8'
}
}
}
stages {
stage('拉取代码') {
steps {
checkout([$class: 'GitSCM', branches: [[name: 'devops']],
extensions: [[$class: 'CloneOption', depth: 1, shallow: true]], userRemoteConfigs: [[url: 'http://gitea.hhdxw.top:3000/yovinchen/xlcs.git']]
])
}
}
stage('编译jar包') {
agent none
steps {
container('maven') {
sh 'mvn -f xlcs-parent/pom.xml -B clean package -Dmaven.test.skip=true -Dautoconfig.skip'
}
}
}
stage('保存制品') {
steps {
archiveArtifacts(artifacts: 'xlcs-parent/service-gateway/target/*.jar', followSymlinks: false)
}
}
stage('构建Docker镜像') {
steps {
sh "docker build -t ${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} xlcs-parent/service-gateway"
}
}
stage('登录仓库并推送镜像') {
steps {
sh "docker login -u ${DOCKER_LOGIN_USERNAME} -p ${DOCKER_LOGIN_PASSWORD} ${DOCKER_REGISTRY}"
sh "docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}"
}
}
}
}