forked from apache/dubbo-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from visenze/dubbo-config
config dubbo
- Loading branch information
Showing
5 changed files
with
278 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
dubbo-admin-server/src/main/resources/application-production.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters