mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 18:49:06 +08:00 
			
		
		
		
	添加Jenkinsfile
This commit is contained in:
		
							
								
								
									
										91
									
								
								Jenkinsfile
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										91
									
								
								Jenkinsfile
									
									
									
									
										vendored
									
									
								
							| @ -1,12 +1,10 @@ | |||||||
|  | #!groovy | ||||||
| pipeline { | pipeline { | ||||||
|   agent { |  | ||||||
|     node { |     agent any | ||||||
|       label 'maven' |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|     parameters { |     parameters { | ||||||
|         string(name:'TAG_NAME',defaultValue: '',description:'') |         string(name: 'TAG_NAME', defaultValue: '', description: '') | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     environment { |     environment { | ||||||
| @ -24,87 +22,32 @@ pipeline { | |||||||
|         GITHUB_ACCOUNT = 'https://gitee.com/zhijiantianya/ruoyi-vue-pro' |         GITHUB_ACCOUNT = 'https://gitee.com/zhijiantianya/ruoyi-vue-pro' | ||||||
|         // 应用名称 |         // 应用名称 | ||||||
|         APP_NAME = 'yudao-admin-server' |         APP_NAME = 'yudao-admin-server' | ||||||
|  |         // 应用部署路径 | ||||||
|  |         APP_DEPLOY_BASE_DIR = '/media/pi/KINGTON/data/work/projects/' | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     stages { |     stages { | ||||||
|         stage ('checkout scm') { |         stage('检出') { | ||||||
|             steps { |             steps { | ||||||
|                 checkout(scm) |                 git url: "https://gitee.com/will-we/ruoyi-vue-pro.git", | ||||||
|  |                         branch: "devops" | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         stage ('unit test') { |         stage('构建') { | ||||||
|             steps { |             steps { | ||||||
|                 container ('maven') { |                 sh 'mvn clean package -Dmaven.test.skip=true' | ||||||
|                     sh 'mvn clean  -gs `pwd`/configuration/settings.xml test' |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         stage ('build & push') { |         stage('部署') { | ||||||
|             steps { |             steps { | ||||||
|                 container ('maven') { |                 sh 'cp -f ' + ' bin/deploy.sh ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" | ||||||
|                     sh 'mvn  -Dmaven.test.skip=true -gs `pwd`/configuration/settings.xml clean package' |                 sh 'cp -f ' + "${env.APP_NAME}" + '/target/*.jar ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" +'/build/' | ||||||
|                     sh 'docker build -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .' |                 archiveArtifacts "${env.APP_NAME}" + '/target/*.jar' | ||||||
|                     withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "$DOCKER_CREDENTIAL_ID" ,)]) { |                 sh 'chmod +x ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" + '/deploy.sh' | ||||||
|                         sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin' |                 sh 'bash ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" + '/deploy.sh' | ||||||
|                         sh 'docker push  $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER' |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         stage('push latest'){ |  | ||||||
|            when{ |  | ||||||
|              branch 'master' |  | ||||||
|            } |  | ||||||
|            steps{ |  | ||||||
|                 container ('maven') { |  | ||||||
|                   sh 'docker tag  $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest ' |  | ||||||
|                   sh 'docker push  $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest ' |  | ||||||
|                 } |  | ||||||
|            } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         stage('deploy to dev') { |  | ||||||
|           when{ |  | ||||||
|             branch 'master' |  | ||||||
|           } |  | ||||||
|           steps { |  | ||||||
|             input(id: 'deploy-to-dev', message: 'deploy to dev?') |  | ||||||
|             kubernetesDeploy(configs: 'deploy/dev-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID") |  | ||||||
|           } |  | ||||||
|         } |  | ||||||
|         stage('push with tag'){ |  | ||||||
|           when{ |  | ||||||
|             expression{ |  | ||||||
|               return params.TAG_NAME =~ /v.*/ |  | ||||||
|             } |  | ||||||
|           } |  | ||||||
|           steps { |  | ||||||
|               container ('maven') { |  | ||||||
|                 input(id: 'release-image-with-tag', message: 'release image with tag?') |  | ||||||
|                   withCredentials([usernamePassword(credentialsId: "$GITHUB_CREDENTIAL_ID", passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { |  | ||||||
|                     sh 'git config --global user.email "kubesphere@yunify.com" ' |  | ||||||
|                     sh 'git config --global user.name "kubesphere" ' |  | ||||||
|                     sh 'git tag -a $TAG_NAME -m "$TAG_NAME" ' |  | ||||||
|                     sh 'git push http://$GIT_USERNAME:$GIT_PASSWORD@github.com/$GITHUB_ACCOUNT/devops-java-sample.git --tags --ipv4' |  | ||||||
|                   } |  | ||||||
|                 sh 'docker tag  $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME ' |  | ||||||
|                 sh 'docker push  $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME ' |  | ||||||
|           } |  | ||||||
|           } |  | ||||||
|         } |  | ||||||
|         stage('deploy to production') { |  | ||||||
|           when{ |  | ||||||
|             expression{ |  | ||||||
|               return params.TAG_NAME =~ /v.*/ |  | ||||||
|             } |  | ||||||
|           } |  | ||||||
|           steps { |  | ||||||
|             input(id: 'deploy-to-production', message: 'deploy to production?') |  | ||||||
|             kubernetesDeploy(configs: 'deploy/prod-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID") |  | ||||||
|           } |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -70,7 +70,6 @@ | |||||||
|             <appender-ref ref="STDOUT"/> |             <appender-ref ref="STDOUT"/> | ||||||
|             <appender-ref ref="ASYNC"/> |             <appender-ref ref="ASYNC"/> | ||||||
|             <appender-ref ref="GRPC"/> |             <appender-ref ref="GRPC"/> | ||||||
|             <appender-ref ref="FILE"/> |  | ||||||
|         </root> |         </root> | ||||||
|     </springProfile> |     </springProfile> | ||||||
|  |  | ||||||
|  | |||||||
							
								
								
									
										41
									
								
								yudao-admin-ui/Jenkinsfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								yudao-admin-ui/Jenkinsfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | |||||||
|  | #!groovy | ||||||
|  | pipeline { | ||||||
|  |  | ||||||
|  |   agent any | ||||||
|  |  | ||||||
|  |   tools { nodejs "nodejs" } | ||||||
|  |  | ||||||
|  |   parameters { | ||||||
|  |     string(name: 'TAG_NAME', defaultValue: '', description: '') | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   environment { | ||||||
|  |     APP_NAME = 'yudao-admin-ui' | ||||||
|  |     NGINX_WORKDIR = '/home/pi/mydata/nginx/html/' | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   stages { | ||||||
|  |     stage('检出') { | ||||||
|  |       steps { | ||||||
|  |         git url: "https://gitee.com/will-we/ruoyi-vue-pro.git", | ||||||
|  |           branch: "devops" | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     stage('构建') { | ||||||
|  |       steps { | ||||||
|  |         sh 'cnpm --prefix '+ "${env.APP_NAME}" +' install' | ||||||
|  |         sh 'cnpm --prefix '+ "${env.APP_NAME}" +' run build:demo1024' | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     stage('部署') { | ||||||
|  |       steps { | ||||||
|  |         sh 'cp -rf ' + "${env.APP_NAME}" + '/dist/. ' + "${env.NGINX_WORKDIR}" | ||||||
|  |         sh 'tar -zcvf ' + "${env.APP_NAME}" + '/'+ "${env.APP_NAME}" + '.tar.gz ' + "${env.APP_NAME}" + '/dist/' | ||||||
|  |         archiveArtifacts  "${env.APP_NAME}" + '/'+ "${env.APP_NAME}" + '.tar.gz' | ||||||
|  |         //TODO 考虑刷新缓存的问题 | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user
	 weir
					weir