2 Star 0 Fork 0

smjg/yygh-parent

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
jekinsfile 12.11 KB
一键复制 编辑 原始数据 按行查看 历史
gongxiaohong 提交于 2023-07-26 11:18 . jekinsfile
pipeline {
agent {
node {
label 'maven'
}
}
stages {
stage('clone code') {
agent none
steps {
container('maven') {
git(url: 'https://gitee.com/smjg_001/yygh-parent.git', credentialsId: 'gitee-id', changelog: true, poll: false)
sh 'ls -a'
}
}
}
stage('项目编译') {
agent none
steps {
container('maven') {
sh 'ls -al'
sh ' mvn clean package -Dmaven.test.skip=true'
}
}
}
stage('default-2') {
parallel {
stage('构建hospital-manage镜像') {
agent none
steps {
container('maven') {
sh 'docker build -t hospital-manage -f hospital-manage/Dockerfile hospital-manage/'
sh 'ls hospital-manage/target'
sh 'ls -al hospital-manage/'
}
}
}
stage('构建service-gateway镜像') {
agent none
steps {
container('maven') {
sh 'docker build -t server-gateway -f server-gateway/Dockerfile server-gateway/'
sh 'ls server-gateway/target'
sh 'ls -al server-gateway/'
}
}
}
stage('构建service-cmn镜像') {
agent none
steps {
container('maven') {
sh 'docker build -t service/service-cmn -f service/service-cmn/Dockerfile ./service/service-cmn/'
sh 'ls service/service-cmn/target'
sh 'ls -al service/service-cmn/'
}
}
}
stage('构建service-hosp镜像') {
agent none
steps {
container('maven') {
sh 'docker build -t service/service-hosp -f service/service-hosp/Dockerfile ./service/service-hosp/'
sh 'ls service/service-hosp/target'
sh 'ls -al service/service-hosp/'
}
}
}
stage('构建service-order镜像') {
agent none
steps {
container('maven') {
sh 'docker build -t service/service-order -f service/service-order/Dockerfile ./service/service-order/'
sh 'ls service/service-order/target'
sh 'ls -al service/service-order/'
}
}
}
stage('构建service-oss镜像') {
agent none
steps {
container('maven') {
sh 'docker build -t service/service-oss -f service/service-oss/Dockerfile ./service/service-oss/'
sh 'ls service/service-oss/target'
sh 'ls -al service/service-oss/'
}
}
}
stage('构建service-sms镜像') {
agent none
steps {
container('maven') {
sh 'docker build -t service/service-sms -f service/service-sms/Dockerfile ./service/service-sms/'
sh 'ls service/service-sms/target'
sh 'ls -al service/service-sms/'
}
}
}
stage('构建service-statistics镜像') {
agent none
steps {
container('maven') {
sh 'docker build -t service/service-statistics -f service/service-statistics/Dockerfile ./service/service-statistics/'
sh 'ls service/service-statistics/target'
sh 'ls -al service/service-statistics/'
}
}
}
stage('构建service-task镜像') {
agent none
steps {
container('maven') {
sh 'docker build -t service/service-task -f service/service-task/Dockerfile ./service/service-task/'
sh 'ls service/service-task/target'
sh 'ls -al service/service-task/'
}
}
}
stage('构建service-user镜像') {
agent none
steps {
container('maven') {
sh 'docker build -t service/service-user -f service/service-user/Dockerfile ./service/service-user/'
sh 'ls service/service-user/target'
sh 'ls -al service/service-user/'
}
}
}
}
}
stage('default-3') {
parallel {
stage('推送hospital-manage镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker tag hospital-manage:latest $REGISTRY/$DOCKERHUB_NAMESPACE/hospital-manage:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/hospital-manage:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送server-gateway镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker tag server-gateway:latest $REGISTRY/$DOCKERHUB_NAMESPACE/server-gateway:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/server-gateway:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送service-cmn镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker tag service/service-cmn:latest $REGISTRY/$DOCKERHUB_NAMESPACE/service-cmn:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/service-cmn:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送service-hosp镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker tag service/service-hosp:latest $REGISTRY/$DOCKERHUB_NAMESPACE/service-hosp:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/service-hosp:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送service-order镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker tag service/service-order:latest $REGISTRY/$DOCKERHUB_NAMESPACE/service-order:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/service-order:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送service-oss镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker tag service/service-oss:latest $REGISTRY/$DOCKERHUB_NAMESPACE/service-oss:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/service-oss:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送service-sms镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker tag service/service-sms:latest $REGISTRY/$DOCKERHUB_NAMESPACE/service-sms:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/service-sms:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送service-statistics镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker tag service/service-statistics:latest $REGISTRY/$DOCKERHUB_NAMESPACE/service-statistics:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/service-statistics:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送service-task镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker tag service/service-task:latest $REGISTRY/$DOCKERHUB_NAMESPACE/service-task:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/service-task:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送service-user镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker tag service/service-user:latest $REGISTRY/$DOCKERHUB_NAMESPACE/service-user:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/service-user:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
}
}
stage('default-4') {
parallel {
stage('部署hospital-manage到dev') {
agent none
steps {
container('maven') {
withCredentials([kubeconfigContent(credentialsId : 'demo-kubeconfig' ,variable : 'KUBECONFIG_CONTENT' ,)]) {
sh '''
#shell判断文件夹是否存在
#如果文件夹不存在,创建文件夹
if [ ! -d "~/.kube" ]; then
mkdir ~/.kube
fi
echo "$KUBECONFIG_CONTENT" > ~/.kube/config
envsubst < hospital-manage/deploy/deploy.yml | kubectl apply -f -
envsubst < server-gateway/deploy/deploy.yml | kubectl apply -f -
'''
}
}
}
}
stage('部署server-gateway到dev') {
agent none
steps {
container('maven') {
sh 'ls'
}
}
}
}
}
}
environment {
ALIYUNHUB_NAMESPACE = 'yygh_gxh'
DOCKER_CREDENTIAL_ID = ''
GITHUB_CREDENTIAL_ID = ''
REGISTRY = 'registry.cn-hangzhou.aliyuncs.com'
DOCKERHUB_NAMESPACE = 'yygh_gxh'
GITHUB_ACCOUNT = ''
APP_NAME = ''
}
parameters {
string(name: 'TAG_NAME', defaultValue: '', description: '')
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/smjg_001/yygh-parent.git
git@gitee.com:smjg_001/yygh-parent.git
smjg_001
yygh-parent
yygh-parent
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385