Commit 919eca95f98f046509d7a5155e1523b6754a2742
1 parent
b4f2e6b1
添加Jenkinsfile
Showing
3 changed files
with
58 additions
and
75 deletions
Jenkinsfile
| 1 | +#!groovy | |
| 1 | 2 | pipeline { |
| 2 | - agent { | |
| 3 | - node { | |
| 4 | - label 'maven' | |
| 5 | - } | |
| 6 | - } | |
| 3 | + | |
| 4 | + agent any | |
| 7 | 5 | |
| 8 | 6 | parameters { |
| 9 | - string(name:'TAG_NAME',defaultValue: '',description:'') | |
| 7 | + string(name: 'TAG_NAME', defaultValue: '', description: '') | |
| 10 | 8 | } |
| 11 | 9 | |
| 12 | 10 | environment { |
| ... | ... | @@ -24,87 +22,32 @@ pipeline { |
| 24 | 22 | GITHUB_ACCOUNT = 'https://gitee.com/zhijiantianya/ruoyi-vue-pro' |
| 25 | 23 | // 应用名称 |
| 26 | 24 | APP_NAME = 'yudao-admin-server' |
| 25 | + // 应用部署路径 | |
| 26 | + APP_DEPLOY_BASE_DIR = '/media/pi/KINGTON/data/work/projects/' | |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | stages { |
| 30 | - stage ('checkout scm') { | |
| 30 | + stage('检出') { | |
| 31 | 31 | steps { |
| 32 | - checkout(scm) | |
| 32 | + git url: "https://gitee.com/will-we/ruoyi-vue-pro.git", | |
| 33 | + branch: "devops" | |
| 33 | 34 | } |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | - stage ('unit test') { | |
| 37 | + stage('构建') { | |
| 37 | 38 | steps { |
| 38 | - container ('maven') { | |
| 39 | - sh 'mvn clean -gs `pwd`/configuration/settings.xml test' | |
| 40 | - } | |
| 39 | + sh 'mvn clean package -Dmaven.test.skip=true' | |
| 41 | 40 | } |
| 42 | 41 | } |
| 43 | 42 | |
| 44 | - stage ('build & push') { | |
| 43 | + stage('部署') { | |
| 45 | 44 | steps { |
| 46 | - container ('maven') { | |
| 47 | - sh 'mvn -Dmaven.test.skip=true -gs `pwd`/configuration/settings.xml clean package' | |
| 48 | - sh 'docker build -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .' | |
| 49 | - withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "$DOCKER_CREDENTIAL_ID" ,)]) { | |
| 50 | - sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin' | |
| 51 | - sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER' | |
| 52 | - } | |
| 53 | - } | |
| 54 | - } | |
| 55 | - } | |
| 56 | - | |
| 57 | - stage('push latest'){ | |
| 58 | - when{ | |
| 59 | - branch 'master' | |
| 60 | - } | |
| 61 | - steps{ | |
| 62 | - container ('maven') { | |
| 63 | - sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest ' | |
| 64 | - sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest ' | |
| 65 | - } | |
| 66 | - } | |
| 67 | - } | |
| 68 | - | |
| 69 | - stage('deploy to dev') { | |
| 70 | - when{ | |
| 71 | - branch 'master' | |
| 72 | - } | |
| 73 | - steps { | |
| 74 | - input(id: 'deploy-to-dev', message: 'deploy to dev?') | |
| 75 | - kubernetesDeploy(configs: 'deploy/dev-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID") | |
| 76 | - } | |
| 77 | - } | |
| 78 | - stage('push with tag'){ | |
| 79 | - when{ | |
| 80 | - expression{ | |
| 81 | - return params.TAG_NAME =~ /v.*/ | |
| 82 | - } | |
| 83 | - } | |
| 84 | - steps { | |
| 85 | - container ('maven') { | |
| 86 | - input(id: 'release-image-with-tag', message: 'release image with tag?') | |
| 87 | - withCredentials([usernamePassword(credentialsId: "$GITHUB_CREDENTIAL_ID", passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { | |
| 88 | - sh 'git config --global user.email "kubesphere@yunify.com" ' | |
| 89 | - sh 'git config --global user.name "kubesphere" ' | |
| 90 | - sh 'git tag -a $TAG_NAME -m "$TAG_NAME" ' | |
| 91 | - sh 'git push http://$GIT_USERNAME:$GIT_PASSWORD@github.com/$GITHUB_ACCOUNT/devops-java-sample.git --tags --ipv4' | |
| 92 | - } | |
| 93 | - sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME ' | |
| 94 | - sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME ' | |
| 95 | - } | |
| 96 | - } | |
| 97 | - } | |
| 98 | - stage('deploy to production') { | |
| 99 | - when{ | |
| 100 | - expression{ | |
| 101 | - return params.TAG_NAME =~ /v.*/ | |
| 45 | + sh 'cp -f ' + ' bin/deploy.sh ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" | |
| 46 | + sh 'cp -f ' + "${env.APP_NAME}" + '/target/*.jar ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" +'/build/' | |
| 47 | + archiveArtifacts "${env.APP_NAME}" + '/target/*.jar' | |
| 48 | + sh 'chmod +x ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" + '/deploy.sh' | |
| 49 | + sh 'bash ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" + '/deploy.sh' | |
| 102 | 50 | } |
| 103 | - } | |
| 104 | - steps { | |
| 105 | - input(id: 'deploy-to-production', message: 'deploy to production?') | |
| 106 | - kubernetesDeploy(configs: 'deploy/prod-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID") | |
| 107 | - } | |
| 108 | 51 | } |
| 109 | 52 | } |
| 110 | 53 | } |
| 111 | 54 | \ No newline at end of file | ... | ... |
yudao-admin-server/src/main/resources/logback-spring.xml
yudao-admin-ui/Jenkinsfile
0 → 100644
| 1 | +#!groovy | |
| 2 | +pipeline { | |
| 3 | + | |
| 4 | + agent any | |
| 5 | + | |
| 6 | + tools { nodejs "nodejs" } | |
| 7 | + | |
| 8 | + parameters { | |
| 9 | + string(name: 'TAG_NAME', defaultValue: '', description: '') | |
| 10 | + } | |
| 11 | + | |
| 12 | + environment { | |
| 13 | + APP_NAME = 'yudao-admin-ui' | |
| 14 | + NGINX_WORKDIR = '/home/pi/mydata/nginx/html/' | |
| 15 | + } | |
| 16 | + | |
| 17 | + stages { | |
| 18 | + stage('检出') { | |
| 19 | + steps { | |
| 20 | + git url: "https://gitee.com/will-we/ruoyi-vue-pro.git", | |
| 21 | + branch: "devops" | |
| 22 | + } | |
| 23 | + } | |
| 24 | + | |
| 25 | + stage('构建') { | |
| 26 | + steps { | |
| 27 | + sh 'cnpm --prefix '+ "${env.APP_NAME}" +' install' | |
| 28 | + sh 'cnpm --prefix '+ "${env.APP_NAME}" +' run build:demo1024' | |
| 29 | + } | |
| 30 | + } | |
| 31 | + | |
| 32 | + stage('部署') { | |
| 33 | + steps { | |
| 34 | + sh 'cp -rf ' + "${env.APP_NAME}" + '/dist/. ' + "${env.NGINX_WORKDIR}" | |
| 35 | + sh 'tar -zcvf ' + "${env.APP_NAME}" + '/'+ "${env.APP_NAME}" + '.tar.gz ' + "${env.APP_NAME}" + '/dist/' | |
| 36 | + archiveArtifacts "${env.APP_NAME}" + '/'+ "${env.APP_NAME}" + '.tar.gz' | |
| 37 | + //TODO 考虑刷新缓存的问题 | |
| 38 | + } | |
| 39 | + } | |
| 40 | + } | |
| 41 | +} | ... | ... |