加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Jenkinsfile 12.07 KB
一键复制 编辑 原始数据 按行查看 历史
明月复苏 提交于 2022-07-02 16:56 . 开源
pipeline {
agent {
node {
label 'maven'
}
}
stages {
stage('clone') {
agent none
steps {
container('maven') {
git(url: 'https://gitee.com/mingyuefusu/party-school-training-system.git', credentialsId: 'gitee-mingyue', branch: 'master', changelog: true, poll: false)
sh 'ls'
}
}
}
stage('build') {
agent none
steps {
container('maven') {
sh 'mvn clean package -Dmaven.test.skip=true'
}
}
}
stage('打包镜像') {
parallel {
stage('构建psedu-gateway镜像') {
agent none
steps {
container('maven') {
sh 'ls psedu-gateway/target'
sh 'docker build -t psedu-gateway:latest -f psedu-gateway/Dockerfile ./psedu-gateway/'
}
}
}
stage('构建psedu-auth镜像') {
agent none
steps {
container('maven') {
sh 'ls psedu-gateway/target'
sh 'docker build -t psedu-auth:latest -f psedu-auth/Dockerfile ./psedu-auth/'
}
}
}
stage('构建psedu-base镜像') {
agent none
steps {
container('maven') {
sh 'ls psedu-modules/psedu-base/target'
sh 'docker build -t psedu-base:latest -f psedu-modules/psedu-base/Dockerfile ./psedu-modules/psedu-base/'
}
}
}
stage('构建psedu-exam镜像') {
agent none
steps {
container('maven') {
sh 'ls psedu-modules/psedu-exam/target'
sh 'docker build -t psedu-exam:latest -f psedu-modules/psedu-exam/Dockerfile ./psedu-modules/psedu-exam/'
}
}
}
stage('构建psedu-file镜像') {
agent none
steps {
container('maven') {
sh 'ls psedu-modules/psedu-file/target'
sh 'docker build -t psedu-file:latest -f psedu-modules/psedu-file/Dockerfile ./psedu-modules/psedu-file/'
}
}
}
stage('构建psedu-gen镜像') {
agent none
steps {
container('maven') {
sh 'ls psedu-modules/psedu-gen/target'
sh 'docker build -t psedu-gen:latest -f psedu-modules/psedu-gen/Dockerfile ./psedu-modules/psedu-gen/'
}
}
}
stage('构建psedu-job镜像') {
agent none
steps {
container('maven') {
sh 'ls psedu-modules/psedu-job/target'
sh 'docker build -t psedu-job:latest -f psedu-modules/psedu-job/Dockerfile ./psedu-modules/psedu-job/'
}
}
}
stage('构建psedu-system镜像') {
agent none
steps {
container('maven') {
sh 'ls psedu-modules/psedu-system/target'
sh 'docker build -t psedu-system:latest -f psedu-modules/psedu-system/Dockerfile ./psedu-modules/psedu-system/'
}
}
}
stage('构建psedu-monitor镜像') {
agent none
steps {
container('maven') {
sh 'ls psedu-visual/psedu-monitor/target'
sh 'docker build -t psedu-monitor:latest -f psedu-visual/psedu-monitor/Dockerfile ./psedu-visual/psedu-monitor/'
}
}
}
}
}
stage('推送镜像') {
parallel {
stage('推送psedu-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 psedu-gateway:latest $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-gateway:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-gateway:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送psedu-auth镜像') {
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 psedu-auth:latest $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-auth:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-auth:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送psedu-base镜像') {
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 psedu-base:latest $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-base:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-base:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送psedu-exam镜像') {
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 psedu-exam:latest $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-exam:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-exam:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送psedu-file镜像') {
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 psedu-file:latest $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-file:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-file:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送psedu-gen镜像') {
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 psedu-gen:latest $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-gen:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-gen:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送psedu-job镜像') {
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 psedu-job:latest $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-job:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-job:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送psedu-system镜像') {
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 psedu-system:latest $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-system:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-system:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('推送psedu-monitor镜像') {
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 psedu-monitor:latest $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-monitor:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/psedu-monitor:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
}
}
stage('部署prod') {
parallel {
stage('psedu-gateway - 部署到prod环境') {
agent none
steps {
kubernetesDeploy(configs: 'psedu-gateway/deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
stage('psedu-auth - 部署到prod环境') {
agent none
steps {
kubernetesDeploy(configs: 'psedu-auth/deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
stage('psedu-base - 部署到prod环境') {
agent none
steps {
kubernetesDeploy(configs: 'psedu-modules/psedu-base/deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
stage('psedu-exam - 部署到prod环境') {
agent none
steps {
kubernetesDeploy(configs: 'psedu-modules/psedu-exam/deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
stage('psedu-file - 部署到prod环境') {
agent none
steps {
kubernetesDeploy(configs: 'psedu-modules/psedu-file/deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
stage('psedu-gen - 部署到prod环境') {
agent none
steps {
kubernetesDeploy(configs: 'psedu-modules/psedu-gen/deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
stage('psedu-job - 部署到prod环境') {
agent none
steps {
kubernetesDeploy(configs: 'psedu-modules/psedu-job/deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
stage('psedu-system - 部署到prod环境') {
agent none
steps {
kubernetesDeploy(configs: 'psedu-modules/psedu-system/deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
stage('psedu-monitor - 部署到prod环境') {
agent none
steps {
kubernetesDeploy(configs: 'psedu-visual/psedu-monitor/deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
}
}
}
environment {
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
GITHUB_CREDENTIAL_ID = 'github-id'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
REGISTRY = 'registry.cn-qingdao.aliyuncs.com'
DOCKERHUB_NAMESPACE = 'ming_k8s_test'
GITHUB_ACCOUNT = 'kubesphere'
APP_NAME = 'devops-java-sample'
ALIYUNHUB_NAMESPACE = 'ming_k8s_test'
}
parameters {
string(name: 'TAG_NAME', defaultValue: '', description: '')
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化