|
|
@@ -1,70 +1,54 @@
|
|
|
-pipeline {
|
|
|
- agent any
|
|
|
+node {
|
|
|
+ // Git checkout before load source the file
|
|
|
+ checkout scm
|
|
|
+
|
|
|
+ def rootDir = pwd()
|
|
|
+ def yaml2Map = load "./sharedLibs/yaml2Map.groovy"
|
|
|
+ def stages = load "./sharedLibs/stages.k8s.groovy"
|
|
|
+ def GLOBAL_CONFIG = yaml2Map.read('global.yaml').project
|
|
|
+
|
|
|
+ jdk = tool name: 'openJDK8'
|
|
|
+ env.JAVA_HOME = "${jdk}"
|
|
|
+
|
|
|
+ dir("poyee-admin/DEV") {
|
|
|
+ def PROJECT_CONFIG = yaml2Map.read('cfg.yaml').project
|
|
|
+ def CONFIG = yaml2Map.merge(PROJECT_CONFIG, GLOBAL_CONFIG)
|
|
|
+ CONFIG.docker.image = String.format(CONFIG.docker.image, CONFIG.service.name)
|
|
|
+ println 'configs: ' + CONFIG
|
|
|
+
|
|
|
+ def generateDockerFile = { ->
|
|
|
+ pathDockerfile = 'projdir'
|
|
|
+ module = CONFIG.service.module
|
|
|
+ module = module == null ? '' : (module[-1] == '/' ? module : module + '/')
|
|
|
+
|
|
|
+ JAR = CONFIG.service.jar
|
|
|
+ sh """cat > ${pathDockerfile}/Dockerfile<<EOF
|
|
|
+# FROM openjdk:8-alpine as final
|
|
|
+# RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
|
|
|
+# apk add --update --nocache ttf-dejavu fontconfig
|
|
|
|
|
|
- stages {
|
|
|
- stage('Example') {
|
|
|
- steps {
|
|
|
- script {
|
|
|
- node {
|
|
|
- checkout scm
|
|
|
- def rootDir = pwd()
|
|
|
- println rootDir
|
|
|
- def yaml2Map = load "./sharedLibs/yaml2Map.groovy"
|
|
|
- def stages = load "./sharedLibs/stages.k8s.groovy"
|
|
|
- def GLOBAL_CONFIG = yaml2Map.read('global.yaml').project
|
|
|
-
|
|
|
- jdk = tool name: 'openJDK8'
|
|
|
- env.JAVA_HOME = "${jdk}"
|
|
|
-
|
|
|
- dir("poyee-admin/DEV") {
|
|
|
-
|
|
|
- def PROJECT_CONFIG = yaml2Map.read('cfg.yaml').project
|
|
|
- def CONFIG = yaml2Map.merge(PROJECT_CONFIG, GLOBAL_CONFIG)
|
|
|
- CONFIG.docker.image = String.format(CONFIG.docker.image, CONFIG.service.name)
|
|
|
- println 'configs: ' + CONFIG
|
|
|
-
|
|
|
- def generateDockerfile = {->
|
|
|
- pathOfDockerfile='projdir'
|
|
|
- module = CONFIG.service.module
|
|
|
- module = module == null ? '' : (module[-1] == '/' ? module : module + '/')
|
|
|
-
|
|
|
- JAR = CONFIG.service.jar
|
|
|
- sh """cat > ${pathOfDockerfile}/Dockerfile<<EOF
|
|
|
FROM registry.cn-shanghai.aliyuncs.com/poyee/openjdk:8-slim
|
|
|
ADD ${module}target/${JAR} /app/target/${JAR}
|
|
|
EOF
|
|
|
"""
|
|
|
- return pathOfDockerfile
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- String[] JAVA_ARGS = ["-Djava.security.egd=file:/dev/./urandom",
|
|
|
- "-Xmx1024m",
|
|
|
- "-Dserver.port=80",
|
|
|
- "-jar", "/app/target/${CONFIG.service.jar}",
|
|
|
- "--spring.config.location=file:/app/configs/application.yml,file:/app/configs/application-druid.yml"]
|
|
|
- String[] K8S_BACKUPS = []
|
|
|
-
|
|
|
- if ("upgrade" == action || "upgrade:selected" == action) {
|
|
|
-
|
|
|
- def base_branch = actionParameter.tokenize('/')[2]
|
|
|
- stages.upgrade(CONFIG, base_branch, K8S_BACKUPS, [
|
|
|
- 'GENERATEDOCKERFILE': {generateDockerfile()},
|
|
|
- 'K3SDEPLOY' : {stages.deployWithConfigmapEnvOnly(CONFIG.service, CONFIG.k3s, base_branch, JAVA_ARGS, "./configmap-env.ini","ahxpm")}
|
|
|
- ])
|
|
|
- }
|
|
|
- sh 'rm -rf projdir/skywalking-agent'
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ return pathDockerfile
|
|
|
}
|
|
|
|
|
|
- stage('Deploy') {
|
|
|
- steps {
|
|
|
- echo "Deployment approved by: ${env.APPROVED_BY}"
|
|
|
- }
|
|
|
+ String[] JAVA_ARGS = [
|
|
|
+ "-Djava.security.egd=file:/dev/./urandom",
|
|
|
+ "-Xmx1536m",
|
|
|
+ "-Dserver.port=80",
|
|
|
+ "-jar", "/app/target/${CONFIG.service.jar}",
|
|
|
+ "--spring.config.location=file:/app/configs/application.yml,file:/app/configs/application-druid.yml"]
|
|
|
+ String[] K8S_BACKUPS = []
|
|
|
+
|
|
|
+ if ("upgrade" == action || "upgrade:selected" == action) {
|
|
|
+
|
|
|
+ def base_branch = actionParameter.tokenize('/')[2]
|
|
|
+ stages.upgrade(CONFIG, base_branch, K8S_BACKUPS, [
|
|
|
+ 'GENERATEDOCKERFILE': generateDockerFile,
|
|
|
+ 'K3SDEPLOY' : {stages.deployWithConfigmaps(CONFIG.service, CONFIG.k3s, base_branch, JAVA_ARGS, "./configmap-env.ini", "ahxpm")}
|
|
|
+ ])
|
|
|
}
|
|
|
}
|
|
|
}
|