|
@@ -0,0 +1,168 @@
|
|
|
+def remote = [:]
|
|
|
+remote.name = "dind-ssh"
|
|
|
+remote.host = "dind"
|
|
|
+remote.port = 22
|
|
|
+remote.user = " "
|
|
|
+remote.password = " "
|
|
|
+remote.allowAnyHosts = true
|
|
|
+
|
|
|
+pipeline {
|
|
|
+ agent any
|
|
|
+
|
|
|
+ environment {
|
|
|
+ // get APPNAME
|
|
|
+ // APPNAME = "Sers"
|
|
|
+ APPNAME = readFile("Publish/DevOps3/environment/env.APPNAME.txt")
|
|
|
+
|
|
|
+ envName = readFile("Publish/DevOps3/environment/env.envName.txt")
|
|
|
+ versionSuffix = "-${envName}${env.build_number}"
|
|
|
+
|
|
|
+ //basePath = "/root/docker-cache/jenkins/jenkins_home/workspace/${APPNAME}/${envName}/${env.BRANCH_NAME}/${env.build_number}"
|
|
|
+ basePath = "${env.WORKSPACE}"
|
|
|
+
|
|
|
+ NUGET_PATH = "/root/docker-cache/jenkins/jenkins_home/workspace/.nuget"
|
|
|
+
|
|
|
+ NUGET_SERVER = "http://nuget.lith.cloud:8"
|
|
|
+ //NUGET_KEY = " "
|
|
|
+ NUGET_KEY = credentials("nuget_key")
|
|
|
+
|
|
|
+ DOCKER_ImagePrefix = "docker.lith.cloud:8/${envName}/"
|
|
|
+ DOCKER_Buildx = false
|
|
|
+ DOCKER_USERNAME = " "
|
|
|
+ DOCKER_PASSWORD = " "
|
|
|
+
|
|
|
+ // set to " " if want to skip save releaseFiles to WebDav
|
|
|
+ WebDav_BaseUrl = "https://pan.lith.cloud:4/remote.php/dav/files/release/releaseFiles/ki_jenkins"
|
|
|
+ // "username:pwd"
|
|
|
+ WebDav_User = credentials("WebDav_User")
|
|
|
+
|
|
|
+ build_crossPlatform = "no"
|
|
|
+
|
|
|
+ dind_ssh_account = credentials("dind_ssh_account")
|
|
|
+ }
|
|
|
+
|
|
|
+ stages {
|
|
|
+ stage('#1 deploy ?') {
|
|
|
+ steps {
|
|
|
+ timeout(time:600,unit:'SECONDS') {
|
|
|
+ script {
|
|
|
+ remote.user = "${dind_ssh_account_USR}"
|
|
|
+ remote.password = "${dind_ssh_account_PSW}"
|
|
|
+
|
|
|
+ env.codePath = "/root/docker-cache/jenkins/" + basePath.substring(5, basePath.length())
|
|
|
+
|
|
|
+ echo "-------- APPNAME: [$APPNAME]"
|
|
|
+ echo "-------- basePath: [$basePath]"
|
|
|
+ echo "-------- DOCKER_ImagePrefix: [$DOCKER_ImagePrefix]"
|
|
|
+ echo "-------- codePath: [$codePath]"
|
|
|
+
|
|
|
+ env.inputChoice = "no"
|
|
|
+ env.inputChoice = input message: "deploy ?",
|
|
|
+ ok: 'Proceed?',
|
|
|
+ parameters: [choice(choices:["yes","no"], description: 'if not please select no', name: 'choice')]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stage('#2 change version') {
|
|
|
+ when { expression { env.inputChoice == "yes" } }
|
|
|
+ steps {
|
|
|
+ script {
|
|
|
+ echo "#2.1 change-app-version"
|
|
|
+ sshCommand remote: remote, command: "sh -c 'set -e; export versionSuffix=$versionSuffix; cd $codePath/Publish/DevOps3/build-bash; source 22.add-suffix-to-app-version.bash; echo -n \"\$nextAppVersion\" > $codePath/Publish/DevOps3/environment/env.appVersion.txt '"
|
|
|
+
|
|
|
+ echo "#2.2 get app version"
|
|
|
+ env.appVersion = readFile("Publish/DevOps3/environment/env.appVersion.txt")
|
|
|
+ echo "-------- appVersion: [${env.appVersion}]"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stage('#3.1 build - single platflorm') {
|
|
|
+ when { expression { env.inputChoice == "yes" } }
|
|
|
+ steps {
|
|
|
+ script {
|
|
|
+ sshCommand remote: remote, command: "sh -c 'set -e; export APPNAME=$APPNAME; export NUGET_PATH=$NUGET_PATH; cd $codePath/Publish/DevOps3/build-bash; sh startup.bash; '"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stage('#3.2 build - cross platform') {
|
|
|
+ when { expression { env.inputChoice == "yes" && env.build_crossPlatform == "yes" } }
|
|
|
+ steps {
|
|
|
+ script {
|
|
|
+ sshCommand remote: remote, command: "sh -c 'set -e; export APPNAME=$APPNAME; export NUGET_PATH=$NUGET_PATH; cd $codePath/Publish/DevOps3/build-bash; sh 40.Station-publish-multiple.bash; '"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stage('#4 publish') {
|
|
|
+ when { expression { env.inputChoice == "yes" } }
|
|
|
+ steps {
|
|
|
+ script {
|
|
|
+ sshCommand remote: remote, command: "sh -c 'set -e; export APPNAME=$APPNAME;export NUGET_PATH=$NUGET_PATH; export NUGET_SERVER=$NUGET_SERVER;export NUGET_KEY=$NUGET_KEY; export DOCKER_Buildx=${env.DOCKER_Buildx};export DOCKER_ImagePrefix=${env.DOCKER_ImagePrefix};export DOCKER_USERNAME=${env.DOCKER_USERNAME};export DOCKER_PASSWORD=${env.DOCKER_PASSWORD};export DOCKER_BuildxExtArgs=\"--output=type=registry,registry.insecure=true\"; cd $codePath/Publish/DevOps3/release-bash; sh startup.bash; '"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stage('#5 save releaseFiles') {
|
|
|
+ when { expression { env.inputChoice == "yes" && env.WebDav_BaseUrl != " " } }
|
|
|
+ steps {
|
|
|
+ script {
|
|
|
+ sshCommand remote: remote, command: "sh -c 'set -e; export basePath=\"$codePath\"; export APPNAME=$APPNAME; export appVersion=\"$appVersion\"; export WebDav_BaseUrl=\"$WebDav_BaseUrl\"; export WebDav_User=\"$WebDav_User\"; cd $codePath/Publish/DevOps3/release-bash; sh 78.push-releaseFiles-to-webdav.bash; '"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stage('#6 deploy') {
|
|
|
+ when { expression { env.inputChoice == "yes" && env.build_deploy == "yes" } }
|
|
|
+ steps {
|
|
|
+ script {
|
|
|
+
|
|
|
+ remote.name = "k8s-ssh"
|
|
|
+ remote.host = "k8s.lith.cloud"
|
|
|
+
|
|
|
+ remote.user = "${k8s_ssh_account_USR}"
|
|
|
+ remote.password = "${k8s_ssh_account_PSW}"
|
|
|
+
|
|
|
+ sshCommand remote: remote, command: "sh -c 'set -e; cd /home/DataStore/Local/Data/2000/200.flowtea-prod/helm; helm upgrade flowtea --set appNum=200 --set debug=true --set resources.limits=false --set image.host=\"\" --set image.tag=\"${env.appVersion}\" --set storageClass.ssd=nfs-prod-ssd --set storageClass.hdd=nfs-prod-hdd ./flowtea -n flowtea; '"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ post {
|
|
|
+ always {
|
|
|
+ timeout(time:3600,unit:'SECONDS') {
|
|
|
+ script {
|
|
|
+ env.inputChoice = "yes"
|
|
|
+ env.inputChoice = input message: "Clean temp files, \n will wait for 3600 seconds. \n click abort to skip clean.",
|
|
|
+ ok: 'Proceed',
|
|
|
+ parameters: [choice(choices:["yes","no"], name: 'choice')]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ script {
|
|
|
+ if ( inputChoice == "yes" ) {
|
|
|
+ echo "clean up workspace directory"
|
|
|
+ cleanWs()
|
|
|
+
|
|
|
+ // clean up tmp directory
|
|
|
+ dir("${workspace}@tmp") {
|
|
|
+ deleteDir()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ success {
|
|
|
+ echo "build success !"
|
|
|
+ }
|
|
|
+ failure {
|
|
|
+ echo "build failure !"
|
|
|
+ }
|
|
|
+ aborted {
|
|
|
+ echo "build aborted !"
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|