diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..2fa827114 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,170 @@ +@Library('visenze-lib')_ + +pipeline { + // choose a suitable agent to build + agent { + label 'build' + } + + options { + timestamps() + } + + parameters { + string(name: 'DOCKER_REGISTRY', defaultValue: '', description: 'leave empty to use dockerhub as registry') + string(name: 'DOCKER_REGISTRY_CREDENTIAL', defaultValue: 'docker-hub-credential', + description: 'The credential ID stored in Jenkins to pull/push to docker registry') + string(name: 'AWS_MAVEN_CREDENTIALS_ID', defaultValue: 'visenze-test-maven-repo') + } + + tools { + maven 'Default' // enable maven + } + + stages { + stage('Checkout') { + steps { + // checkout the code from scm (github) + checkout scm + } + } + + stage('Package') { + steps { + script { + sh "mvn clean compile package install" + } + } + } + + stage('Docker Build') { + when { + expression { + return doBuildAndTest(env.BRANCH_NAME) + } + } + steps { + script { + // assume the Dockerfile is directly under WORKSPACE + def commitHash = getCommit() + // get jar build version for cas-server (version inherit from cas-parent) + def jarVersion = readMavenPom(file: 'pom.xml').version + echo "jarVersion ${jarVersion}" + // pull build image + docker.withRegistry(params.DOCKER_REGISTRY, params.DOCKER_REGISTRY_CREDENTIAL) { + // assume the docker registry is visenze/dubbo-admin + docker.build("visenze/dubbo-admin:${commitHash}", "-f docker/Dockerfile .") + } + } + } + } + + stage('Docker Push') { + when { + expression { + return doBuildAndTest(env.BRANCH_NAME) + } + } + steps { + script { + def commitHash = getCommit() + def version = getVersion() + docker.withRegistry(params.DOCKER_REGISTRY, params.DOCKER_REGISTRY_CREDENTIAL) { + def image = docker.image("visenze/dubbo-admin:${commitHash}") + // push all the tags + def tags = genDockerTags(env.BRANCH_NAME, commitHash, version, env.BUILD_NUMBER) + // keep the last tag as a global variable used by later stages + TAG = tags[-1] + tags.add(commitHash) + + tags.each { + retry(2) { + image.push(it) + } + } + } + } + } + } + + + stage('Archive') { + when { + expression { + return doBuildAndTest(env.BRANCH_NAME) || isProdRelease(env.BRANCH_NAME) + } + } + steps { + script { + def archive = [ + docker_tag: TAG, + version: getVersion(), + docker_repos: ['visenze/dubbo-admin'] + ] + writeFile(file: "${WORKSPACE}/version.json", text: groovy.json.JsonOutput.toJson(archive)) + archiveArtifacts(artifacts: "version.json", allowEmptyArchive: true) + } + } + } + } + +} + + + +// Get commit sha +def getCommit() { + return sh( + script: "(cd '${WORKSPACE}'; git rev-parse HEAD)", returnStdout: true + ).trim() +} + +def getVersion() { + // read version from pom + return readMavenPom(file: 'pom.xml').version +} + +// Get snapshot version +def genSnapShotVersion(version) { + def suffix = "-SNAPSHOT" + if (!version.endsWith(suffix)) { + return version + suffix + } + return version +} + +// Get Release version +def genReleaseVersion(version) { + def suffix = "-SNAPSHOT" + if (version.endsWith(suffix)) { + return version.substring(0, version.length() - suffix.length()) + } + return version +} + +def genDockerTags(branch, commit, version=null, buildNumber=null) { + def tags = [] + def shortCommit = commit.substring(0, 9) + tags.add(branch.replaceAll("/", "_")) + tags.add("${branch.replaceAll("/", "_")}-${shortCommit}") + //if(branch == 'production') { + // assert version !=null + // tags.add("${version}") + //} else { + // assert version != null && buildNumber != null + // tags.add("${version}.${buildNumber}-${shortCommit}") + //} + return tags +} + +def isPullRequest(branch) { + return branch.startsWith('PR') +} + +def doBuildAndTest(branch) { + return branch.startsWith('PR') || branch == 'staging' || branch == 'production' +} + +def isProdRelease(branch) { + return env.BRANCH_NAME == "production" +} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..07654c154 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,7 @@ +FROM openjdk:8-jdk + +COPY ./dubbo-admin-distribution/target/dubbo-admin-0.2.0-SNAPSHOT.jar / + +EXPOSE 8080 + +CMD ["java", "-jar", "/dubbo-admin-0.2.0-SNAPSHOT.jar"] diff --git a/dubbo-admin-server/pom.xml b/dubbo-admin-server/pom.xml index 54cb8e10d..dffede41c 100644 --- a/dubbo-admin-server/pom.xml +++ b/dubbo-admin-server/pom.xml @@ -166,6 +166,53 @@ dubbo-serialization-kryo + + org.apache.dubbo + dubbo-rpc-rest + 2.7.7 + + + org.apache.dubbo + dubbo-rpc-http + 2.7.7 + + + + com.esotericsoftware + kryo + 4.0.2 + + + de.javakaffee + kryo-serializers + 0.45 + + + org.apache.dubbo + dubbo-serialization-fst + 2.7.8 + + + org.apache.dubbo + dubbo-serialization-avro + 2.7.8 + + + org.apache.dubbo + dubbo-serialization-gson + 2.7.8 + + + org.apache.dubbo + dubbo-serialization-fastjson + 2.7.8 + + + org.apache.dubbo + dubbo-rpc-rmi + 2.7.8 + + org.mockito mockito-core diff --git a/dubbo-admin-server/src/main/resources/application-production.properties b/dubbo-admin-server/src/main/resources/application-production.properties new file mode 100644 index 000000000..76a8b3090 --- /dev/null +++ b/dubbo-admin-server/src/main/resources/application-production.properties @@ -0,0 +1,45 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# centers in dubbo2.7 +admin.registry.address=zookeeper://zk-prod-cs:2181 +admin.config-center=zookeeper://zk-prod-cs:2181 +admin.metadata-report.address=zookeeper://zk-prod-cs:2181 + +admin.root.user.name=root +admin.root.user.password=root +#group +admin.registry.group=dubbo +admin.config-center.group=dubbo +admin.metadata-report.group=dubbo + +admin.apollo.token=e16e5cd903fd0c97a116c873b448544b9d086de9 +admin.apollo.appId=test +admin.apollo.env=dev +admin.apollo.cluster=default +admin.apollo.namespace=dubbo + +#compress +server.compression.enabled=true +server.compression.mime-types=text/css,text/javascript,application/javascript +server.compression.min-response-size=10240 +server.port=8080 + +dubbo.protocol.id=dubbo +dubbo.protocol.name=dubbo +dubbo.protocol.port=-1 +dubbo.protocol.serialization=fst diff --git a/dubbo-admin-server/src/main/resources/application.properties b/dubbo-admin-server/src/main/resources/application.properties index e8cb6a85b..ee8b93af0 100644 --- a/dubbo-admin-server/src/main/resources/application.properties +++ b/dubbo-admin-server/src/main/resources/application.properties @@ -16,9 +16,9 @@ # # centers in dubbo2.7 -admin.registry.address=zookeeper://127.0.0.1:2181 -admin.config-center=zookeeper://127.0.0.1:2181 -admin.metadata-report.address=zookeeper://127.0.0.1:2181 +admin.registry.address=zookeeper://zookeeper:2181 +admin.config-center=zookeeper://zookeeper:2181 +admin.metadata-report.address=zookeeper://zookeeper:2181 admin.root.user.name=root admin.root.user.password=root @@ -37,3 +37,9 @@ admin.apollo.namespace=dubbo server.compression.enabled=true server.compression.mime-types=text/css,text/javascript,application/javascript server.compression.min-response-size=10240 +server.port=8080 + +dubbo.protocol.id=dubbo +dubbo.protocol.name=dubbo +dubbo.protocol.port=-1 +dubbo.protocol.serialization=fst